{
  "openapi": "3.1.0",
  "info": {
    "title": "Isaac Core Banking API",
    "version": "0.35.0",
    "description": "Core banking API for banks and financial institutions supervised in\nSwitzerland, including institutions with a FinTech licence under Art. 1b\nof the Banking Act.\n\nIsaac follows the Coreless Banking pattern: the ledger is a\nseparate engine, immutable and append-only. Business logic sits above it.\nNothing in the application layer can violate double-entry integrity or\noverdraft rules \u2014 the engine enforces those constraints before any write\nis acknowledged.\n\nIsaac provides technical controls and evidence for regulated\nfinancial operations. It holds no licence and does not make an\ninstitution compliant on its own: compliance depends on the licensed\ninstitution, the obligations of its jurisdiction, its operational\nprocedures, provider contracts, and independent legal validation.\n\n## Scope Boundary\n\nThis specification describes platform capabilities. Not every capability\nis enabled for every tenant, licence, or production deployment. Regulated\nservices depend on the licensed institution, provider setup, contractual\nscope, local legal assessment, and operational controls.\n\nModules such as cards, cash deposits, SWIFT, FX, and branch operations are\noptional and may be excluded from an institution's initial audit scope.\n\n## Control Principles\n\nThe controls below do not depend on one jurisdiction's law. Which rules\nrequire them, and with which parameters, is configured per tenant: licence\npack, regime, jurisdiction profile (retention, calendars, chart of\naccounts), CDD policies, and enabled payment rails.\n\n| Principle | What the platform provides |\n|-----------|----------------------------|\n| Customer due diligence | KYC/KYB workflow, beneficial owners, risk scoring, enhanced due diligence triggers, periodic review by policy |\n| Sanctions and PEP screening | Screening of customers, beneficiaries, and payment counterparties through the configured provider; ongoing monitoring; a hold for manual review when the provider fails |\n| Suspicious activity | Alerts, cases, MLRO decisions, and reports exported for the national Financial Intelligence Unit |\n| Strong authentication | MFA for staff; for customers, approval on their bound phone bound to the amount and payee of each payment and card change, with the mode and exemptions set per tenant; OAuth2 client credentials for integrations |\n| Audit trail | Append-only ledger, SHA-256 hash-chained audit log, four-eyes approval where configured |\n| Data protection | Tenant isolation by row-level security, role-based access, retention per jurisdiction, erasure of support data on request |\n| ICT risk and resilience | Health and readiness probes, metrics, durable workflows with retry and compensation, evidence for incident handling |\n| Client funds | Separate ledger accounts per tenant and currency; safeguarding accounts and reconciliation where the licence requires them |\n\n## Regulatory Scope\n\nIsaac serves the Swiss market only; the frameworks below are its\nreference set. The platform supports compliance with them; it does not\nreplace the institution's licence, policies, or legal assessment.\n\n| Framework | Reference | Supported by |\n|-----------|-----------|--------------|\n| **Banking Act** | Banking Act (BankA, SR 952.0) and Banking Ordinance (BankO, SR 952.02); FinTech licence under Art. 1b BankA | Licence pack per tenant (`art_1b`), cap on accepted public deposits (CHF 100 million for Art. 1b) with an intake latch, depositor-protection notice on statements |\n| **Anti-money laundering** | Anti-Money Laundering Act (AMLA, SR 955.0); FINMA Anti-Money Laundering Ordinance (AMLO-FINMA, SR 955.033.0) | Identification of the contracting party and the beneficial owner, risk-based enhanced due diligence, periodic CDD review, record keeping (AMLA Art. 7), reports to MROS (AMLA Art. 9) with a goAML export, the asset freeze clock (AMLA Art. 10) |\n| **Sanctions** | Embargo Act (EmbA, SR 946.231) and the SECO sanctions ordinances | Screening of customers, beneficiaries, and payments through the configured provider; separate SECO and MROS paths in a sanctions case |\n| **Operational risk and resilience** | FINMA Circular 2023/1 \"Operational risks and resilience \u2013 banks\" | Evidence for ICT and cyber risk management, critical data, and operational resilience: hash-chained audit trail, monitoring, durable workflows |\n| **Outsourcing** | FINMA Circular 2018/3 \"Outsourcing\" | Where the institution outsources to the platform operator: controls and evidence for its outsourcing assessment |\n| **Incident reporting** | Art. 29 para. 2 FINMASA | Evidence from the audit trail and monitoring for reports of material incidents to FINMA |\n| **Data protection and banking secrecy** | Federal Act on Data Protection (FADP, SR 235.1, revised, in force since 1 September 2023); Art. 47 BankA | Tenant isolation, role-based access with audited case views, data minimisation in logs, retention per jurisdiction, erasure of support data on request |\n| **Swiss payments** | SIC and SIC IP (Swiss National Bank, operated by SIX); Swiss Payment Standards (ISO 20022 implementation guidelines) | Rail selection and status for CHF payments on SIC and SIC IP; ISO 20022 message models (pain.001, pacs.008, pacs.002, pacs.004, camt.056) and camt.053 statements |\n\nPayments with counterparties abroad, for example SEPA payments in EUR,\nalso follow the scheme rules of the rail used.\n\n## Architecture\n\nThe platform follows a three-risk-layer architecture with four technical\ncomponents:\n\n- **Ledger** (Critical Layer) \u2014 Dedicated engine. Immutable double-entry\n  accounting, strict serialisability, batch processing. No SQL, no ORM.\n- **Domain** (Control Layer) \u2014 Business rules, tenant feature flags,\n  transfer limits, regulatory checks. Written in Zig, statically linked.\n- **Integration** (Integration Layer) \u2014 Provider abstraction for payment\n  rails (credit transfers, instant payments, direct debits, SWIFT, card\n  networks) and IBAN generation with ISO 13616 check digits.\n- **Access** (Access Layer) \u2014 Admin UI (RBAC + MFA) and OAuth2 tenant API.\n\n## The Ledger Engine\n\nThis isn't a general-purpose database pressed into service as a ledger.\nIt's a purpose-built OLTP engine for financial accounting.\n\n**Correctness.** Strict serializability \u2014 the strongest isolation level.\nEvery transaction is atomic, real-time, with no anomalies and no clock\nassumptions. Double-entry balance integrity, overdraft prevention, and\nidempotency are engine-level invariants, not application-level checks.\n\n**Throughput.** Transfers execute in large batches without lock contention.\nHot accounts (the ones that break conventional databases under load)\ndon't degrade performance here.\n\n**Latency.** Static memory allocation, no GC, no deserialization overhead.\nLatency is predictable because there's nothing non-deterministic in the\nexecution path.\n\n**Immutability.** No UPDATE. No DELETE. Every entry is permanent.\nReconciliation becomes straightforward when the ledger can't contradict\nitself.\n\n**Durability.** Replicated write-ahead log with quorum-based sync commits.\n128-bit end-to-end checksums protect against corruption and misdirected\nI/O. The storage fault model handles gray failures (hardware degrading\nsilently) and routes around them.\n\n## Authentication\n\nTwo mechanisms, both issuing Bearer tokens:\n\n1. **Admin Session** \u2014 `POST /api/v1/auth/login`. Supports MFA via TOTP\n   (RFC 6238), automatic expiry, inactivity warnings. Five roles:\n   `super_admin`, `admin`, `compliance_officer`, `mlro`, `viewer`.\n2. **OAuth2 Client Credentials** \u2014 `POST /oauth/token`. Time-limited\n   access token for tenant integrations. Scoped to specific permissions\n   (`accounts:read`, `transfers:write`, etc.). The gateway's ForwardAuth\n   injects `X-Tenant-ID` and `X-Tenant-Env` after verification.\n\n## Staff Access\n\nEvery admin session request meets the staff route gate (DEC-0043)\nbefore any handler: a table names, per route and method, the roles of\na bank's cell (`bank_admin`, `mlro`, `bank_staff`, `auditor`, `coo`,\n`cfo`, `recovery_manager`, `key_account_manager`) and whether the\nplatform `super_admin` may use it. A role the rule does not name, and a\nroute without a rule, answer 403\n`{\"error\":{\"code\":\"forbidden_role\",\"message\":\"...\"}}` with nothing\nchanged. Deny by default. The support roles and desk sessions keep the\nsupport desk's own list; `X-Service-Key` calls and customer JWTs do not\nmeet this gate. Handlers still check scope, tenant and four-eyes.\n\n- Platform-only writes: FX reference rates and global spreads,\n  reconciliation, jurisdictions and holidays, KYC provider\n  configuration, feature flags, the integrations registry, the\n  settlement scheduler and a tenant's ceilings\n  (`PATCH /api/v1/tenants/{tenantId}/settings`).\n- Cases, suspicious activity reports, alert and screening decisions,\n  KYB, CDD check and KYC decisions and the screening watchlist are\n  written by the bank's `mlro` only; the platform `super_admin` reads\n  and exports them. Account and wallet freeze, unfreeze, close and\n  write-off, customer activation, suspension and closure, cash deposits\n  (create, approve, reject, reprocess), transfer split and cancel, and\n  transfer approval decisions (approve, reject, re-dispatch) are the\n  bank's only too. The platform `super_admin` gets 403\n  `platform_read_only` on these and on the case, SAR, KYC, screening and\n  alert decisions.\n- Reconciliation is the platform's, reads included, until its records\n  carry the tenant.\n- The bank's own fee overrides, limits, holding periods and posting\n  rules, deletes included, are `bank_admin`'s.\n- A tenant's SCA policy is read by the bank's own roles and written by\n  the platform only.\n- The `auditor` reads the whole AML programme: the rule book, its\n  changes and revisions, monitoring rules and hits, screening\n  thresholds and their history, CDD policies and the case workflow. It\n  writes none of them.\n\n### Platform assist\n\nThe platform `super_admin` helps, the bank decides. It reads every\nbank's data, the helpdesk included (`GET /api/v1/support/...`, read\nonly). A read of a customer, a compliance case, a suspicious activity\nreport or a helpdesk conversation is written to that bank's staff\naccess log (officer activity `CUSTOMER_OPENED`, `CASE_OPENED`,\n`SAR_OPENED`, `SUPPORT_CASE_OPENED`); a read whose log row cannot be\nwritten answers 503 `access_log_unavailable`.\n\nIt changes a bank's own settings on the bank's behalf: fees and special\npricing, limits and customer overrides, the card FX cap, holding\nperiods, posting rules, unassigned bookings, closure policies, support\nsettings (queues, SLA policies, calendar, hours and closures, macros,\nhelp articles, settings, request templates, topics), the webhook\nendpoint, screening thresholds, and as the maker of a four-eyes request\nmonitoring rule changes and the case workflow. It changes the bank's\nrecords the same way: card and wallet limits, account create, customer\ncreate and update, customer members, beneficiaries, KAM assignments,\nKYC submission and session start, and outgoing notification retries. Such a request names the\nbank in `X-Tenant-ID` (400 `tenant_required`), names no other bank in\nthe query or body (403 `tenant_mismatch`) and carries a reason of 10 to\n1000 characters in the `X-Change-Reason` header (percent-encoded UTF-8)\nor the `reason` query parameter (400 `reason_required`). Every audit\nrow it writes names the `super_admin` as actor and carries\n`platform_operator`, `acting_for_tenant`, `platform_operator_id`,\n`platform_operator_email` and `platform_reason` in its data; a change\nthat writes no row of its own gets one\n(`platform_operator.bank_change`).\n\nFour-eyes stays with the bank: the platform may ask, and an officer of\nthat bank decides. The platform as approver (or as the rejecter of\nanother officer's request) answers 403 `checker_must_be_bank_officer`.\n\nThe acting officer is the session's, never a request field: for an\nadmin session `X-Actor-Email` and body fields such as `processed_by`,\n`approved_by`, `rejected_by`, `created_by`, `updated_by`,\n`assigned_by` and `archived_by` are ignored. Only a service call names\nthe person.\n\n## Tenant Isolation\n\nEvery tenant-scoped operation is isolated through:\n- Row-Level Security at the database layer\n- `X-Tenant-ID` header injected by the gateway (never client-supplied)\n- Separate ledger codes per currency per tenant\n- Per-tenant feature flags and limits (SEPA, FX, cards)\n\n## Member Roles (customer JWT)\n\nA customer JWT carries the member `role` of its customer: `owner`,\n`admin`, `accounting`, or `customer` (an individual, or a business login\nwithout a member row). `accounting` is read-only. Before any handler,\nevery money, card, wallet and payee write (transfers, FX convert, card\nstatus, limits, label, account, suspend, terminate and rule, card rules,\ncard request, wallet create, rename, freeze, unfreeze and close, payees\nand beneficiaries) and the card data reveal\n(`GET /api/v1/cards/{id}/sensitive`) answer 403\n`{\"error\":\"forbidden_role\"}` for `accounting` (and any unknown role), with\nnothing changed and no provider called. An impersonation session answers\n403 `{\"error\":\"read_only_session\"}` on the same routes. Reads (wallets,\ntransactions, card lists, masked card details) stay open to every role.\nAdmin sessions and `X-Service-Key` calls are not affected.\nMember management (`POST`, `PATCH`, `DELETE /api/v1/customers/{id}/members\u2026`)\nand `POST /api/v1/customers/{id}/initiate-closure` are owner only\n(`customer` keeps its access to its own customer); `admin` and\n`accounting` get 403 `forbidden_role`.\n\n## Idempotency\n\nAll mutating financial operations require an `Idempotency-Key` header\n(UUID v4). Duplicate requests return the original response without\nre-execution. This is how you prevent double-spending on retries.\n\n## Monetary Amounts\n\nAll values are **minor units** (smallest denomination), 64-bit integers.\nNo floating point, ever.\n\n| Currency | Unit | Example |\n|----------|------|----------|\n| CHF | rappen | 100.00 CHF = `10000` |\n| EUR | cent | 100.00 EUR = `10000` |\n| USD | cent | 1,234.56 USD = `123456` |\n| GBP | penny | 50.75 GBP = `5075` |\n| *others* | smallest unit | all values always integers |\n\n## Errors\n\nConsistent envelope: `{ \"error\": \"description\" }`. HTTP status codes per\nRFC 9110. Business rule violations (insufficient funds, limit breach,\nfeature disabled) return `422`; malformed input returns `400`.\n\nA write (POST, PUT, PATCH, DELETE) whose request target (path and query)\nis longer than 2048 bytes returns `414` `{\"error\":\"uri_too_long\"}` and\nchanges nothing.\n\n## Versioning\n\nURI path versioning (`/api/v1/`). Breaking changes increment the version.\nAdditive changes (new fields, new endpoints) ship without a bump.\n",
    "contact": {
      "name": "Isaac Core Banking Team",
      "email": "hello@corebank.ch"
    },
    "license": {
      "name": "Proprietary",
      "identifier": "LicenseRef-Proprietary"
    }
  },
  "servers": [
    {
      "url": "https://api.corebank.ch",
      "description": "API Server"
    }
  ],
  "tags": [
    {
      "name": "Health",
      "description": "Liveness and readiness probes. The readiness check validates connectivity\nto the ledger engine and the metadata database independently \u2014 if either\nis down, the service reports not ready. Used by orchestrators and load\nbalancers for routing decisions.\n"
    },
    {
      "name": "Auth",
      "description": "Admin authentication. Sessions have a configurable TTL with inactivity\nwarnings before expiry. MFA uses TOTP (RFC 6238). Five RBAC roles\ncontrol what each admin can see and do. Account lockout kicks in after\nrepeated failures (OWASP guidelines). Passwords are stored as Argon2id\nhashes.\n"
    },
    {
      "name": "OAuth",
      "description": "Client Credentials grant (RFC 6749 \u00a74.4) for machine-to-machine\naccess. `/verify` is the ForwardAuth endpoint: it validates the\nBearer token and injects `X-Tenant-ID` and `X-Tenant-Env` into\nthe upstream request. Tenant isolation is enforced here, at the\ngateway, before the request reaches the API.\n"
    },
    {
      "name": "Credentials",
      "description": "API credential management for tenant integrations. Each credential is\na `client_id` / `client_secret` pair, scoped to an environment (sandbox\nor production) and a set of permissions. Rotation is atomic: revoke\nand reissue in one call. The secret is shown once at creation and\nstored as an irreversible hash.\n"
    },
    {
      "name": "Tenants",
      "description": "Tenant lifecycle management. Each tenant is a licensed entity (fintech,\nbank, or platform operator) with its own feature flags, transfer limits,\nwebhook config, and API credentials. State machine:\n`pending -> active -> suspended -> terminated`. Every transition is\naudited. Ledger configuration is isolated per tenant, which supports\nsegregation of client funds where the licence requires it.\n"
    },
    {
      "name": "Customers",
      "description": "Customer onboarding and KYC/AML workflow. Individuals and business\nentities, with address, tax ID, and beneficial ownership data.\nKYC follows four states: `pending -> in_review -> verified | rejected`.\nEvery state change is recorded for AML record keeping.\nCustomer members handle multi-signatory and corporate access.\n"
    },
    {
      "name": "KycConfig",
      "description": "KYC/KYB verification configuration and provider session management\n(BR-EF-013). Per-tenant verification flows with configurable steps\n(ID document, liveness, proof of address, AML screening). Sessions\nare created via the KYC provider widget API and tracked through callback\nwebhooks. Auto-approve logic transitions customer KYC status when\nsimilarity exceeds the configured threshold.\n"
    },
    {
      "name": "CDD",
      "description": "Customer Due Diligence address management, risk assessment, policy\nengine, and check lifecycle (BR-EF-016). Addresses use SCD Type 2\n(Slowly Changing Dimension) for immutable history. Policies define\nverification requirements by jurisdiction, risk level, and customer\ntype. Checks follow a state machine: pending -> in_progress ->\ncompleted/failed/escalated/cancelled. Address changes automatically\ntrigger CDD checks when a matching policy exists.\n"
    },
    {
      "name": "Screening",
      "description": "Sanctions screening integration (BR-EF-026).\nReal-time screening of individuals, entities, and beneficiaries\nagainst 49+ global sanctions lists, PEP databases, and adverse media.\nDecision logic: no_match (proceed), auto_cleared (below threshold),\npotential_match (MLRO review queue). Fail-safe: a provider error holds\nthe account for manual review. Continuous monitoring via scheduled workflow.\nCircuit breaker protects against provider outages.\n"
    },
    {
      "name": "Accounts",
      "description": "Bank account management across the IBAN registry and the ledger.\nEight account types, including safeguarding accounts for institutions\nthat must safeguard client funds: `customer_emoney`,\n`platform_fees`, `platform_fx`, `safeguarding`, `safeguarding_backup`,\n`nostro`, `suspense`, `float_account`. Lifecycle is\nactive/frozen/closed \u2014 you can't close an account with a non-zero\nbalance. State transitions are audit-trailed. Balance queries read\ndirectly from the ledger, not from a cache or replica.\n"
    },
    {
      "name": "Wallets",
      "description": "A wallet holds one ledger account per currency (`account_ids`); the\nwallet's own `currency` is the one it was created with. Only the\nprimary wallet's own currency is the customer's Main account\n(`account_ids[].is_main`, `main_currency`; BR-CP-003 \u00a74.4). Customers\nmay have multiple wallets per currency; uniqueness\nis enforced by wallet name per customer (migration 059). The primary\nwallet (`is_primary: true`) is auto-created on KYC verification and\ncannot be closed or frozen. Credits, debits, and spending limits\n(daily, monthly, per-transaction) are all supported. Freeze a wallet\nto block funds immediately for fraud or compliance holds without\nclosing it. Balances come straight from the ledger. The customer-scoped\nlist endpoint excludes closed wallets and orders primary wallets first;\nthe admin list endpoint returns all wallets including closed ones.\n"
    },
    {
      "name": "Transfers",
      "description": "Atomic ledger transfers. A single transfer moves funds between two\naccounts. Split transfers link up to 16 legs that succeed or fail\ntogether. A customer caller passes strong customer authentication\n(SCA, `X-SCA-Token`) on every transfer unless an exemption of its\ntenant applies; see `POST /api/v1/transfers`. Each transfer carries bi-temporal metadata\n(value date, booking date) and triggers a webhook on completion.\n"
    },
    {
      "name": "Fees",
      "description": "Tiered fee engine (BR-EF-021). Fee schedules define per-event-type\npricing with volume-based tiers (flat or percentage). Customer-specific\noverrides take precedence over default schedules. Fee calculation preview\nis mandatory before transfer confirmation. Fee amounts\nare recorded on transfer metadata for audit and reconciliation.\n"
    },
    {
      "name": "Holds",
      "description": "Reserve-capture-void pattern for card acquiring and pre-authorised\npayments. A hold creates a pending transfer that reserves funds\nwithout settling. Capture finalises it (partial capture is supported).\nVoid releases the reservation. Holds expire after a configurable\ntimeout (default 7 days, per card scheme rules).\n"
    },
    {
      "name": "Limits",
      "description": "Transaction limits at three levels: tenant, customer, and account.\nThe most specific limit wins (account > customer > tenant). Each\nlevel supports single-transaction, daily, and monthly thresholds\nper currency. Limits are checked during transfer creation, before\nanything hits the ledger.\n"
    },
    {
      "name": "FX",
      "description": "Foreign exchange: rates, quotes, conversions, and bank operations\nmanagement. Rates come from a rate provider (real-time) with static\nfallback and a two-tier cache (in-memory 30min, database 1h). Quotes\nhave a limited validity window. Conversions execute as atomic\ncross-ledger transfers. Bank operations personnel can override rates\nmanually, configure per-pair spreads, and review the rate change\naudit trail. Tenant-level feature flags gate FX access. Full\nmulti-currency support: CHF, EUR, and USD are primary; GBP, PLN, SEK,\nNOK, DKK, CZK available. Additional currencies\ncan be added on request without schema changes.\n"
    },
    {
      "name": "Insights",
      "description": "Money insights for the JWT customer (BR-FM-012, first slice). Read only,\ncomputed on request from the customer's ledger transfers and card\nauthorizations. Every response names `method` (`rules_v1`). Money is\nminor units plus ISO currency, per currency. Notes and brief lines are\ntranslation keys plus params, never prose. Admin sessions get 403.\n"
    },
    {
      "name": "Cards",
      "description": "Card issuing and lifecycle management (BR-EF-017).\nCards are issued through durable workflows that orchestrate\ncard network API calls, database metadata storage, and audit logging.\nCard states follow standard conventions: `unactivated -> active ->\nsuspended <-> active -> terminated`. Spending limits (per-transaction,\ndaily, monthly) are enforced at the JIT funding gateway. Authorization\nholds use ledger engine two-phase transfers for real-time balance checks.\n"
    },
    {
      "name": "CardGateway",
      "description": "Inbound card network provider integration endpoints (BR-EF-017). Two entry points:\nthe **JIT Funding Gateway** receives real-time authorization requests\nfrom the card network provider (must respond < 2 seconds with HTTP 200 approve or\nHTTP 402 decline), and the **Webhook Handler** receives async event\nnotifications (clearing, reversal, refund, card lifecycle). Both use\nHTTP Basic Auth with separate credential pairs. The webhook handler\ndeduplicates via `event_token` UNIQUE constraint and dispatches to\nworkflow engine services for durable processing.\n"
    },
    {
      "name": "Cash Deposits",
      "description": "Optional module. Included only where branch or cash-acceptance operations\nare in scope. May extend AML reporting obligations. Exclude from audit\nscope unless branch cash operations are explicitly in scope.\n\nBranch cash deposit processing with AML compliance (BR-EF-020).\nDeposits are automatically checked against a fixed daily aggregate\nthreshold of 10,000 EUR per customer. Deposits exceeding the\nthreshold or triggering compliance flags (structuring, third-party,\nmissing source-of-funds) require 4-eyes approval before funds are\ncredited to the customer wallet. The processing officer and approving\nofficer must be different persons.\n"
    },
    {
      "name": "HoldingPeriods",
      "description": "Settlement-before-availability logic for SEPA Direct Debit transactions\n(BR-EF-011). The holding period applies per payment method (`SEPA_SDD`,\n`SEPA_SDD_B2B` from the booking's transaction code), per customer, or\nper bank rule whose `customer_group` (the customer type) and\n`risk_score` (the customer's risk level) are empty or match; without a\nrule, 5 calendar days. Business days count on the calendar of the\nbank's jurisdiction plus TARGET2, in its time zone, to the end of the\nN-th business day after the receipt day.\n\nLedger hold (migration 287, feature flag\n`feature.payments.holding_ledger_hold` per bank, default off): the\ncredit of an incoming direct debit is posted to the ledger as a\npending transfer. The customer's available balance excludes it; it\nshows as pending credits (`on_hold` of the wallet balances,\n`pending_credits` of the account balances) and the transfer as\n`pending` in the history until the settlement scheduler posts it at\nthe end of the period. The scheduler releases ledger holds also while\nits record-only switch is off. Held credits count in the deposit cap\nutilisation (Art. 1b packs) from their records, so intake is refused\nwhile the bank is over its cap; a release is never withheld for the\ncap (over the cap: released, one alert). A hold the ledger shows\nposted another way is recorded as the ledger shows it, with an alert.\nA failed release sends the hold to the back of the due list; a hold\nrefused 20 times (outages do not count) is skipped with an alert.\nHolds overdue by more than 6 hours, skipped ones and stale figures\nshow in `GET /health/schedulers` (`ledger_holds`) and in /metrics. An\nR-transaction while it is held voids it: the customer is never\ndebited, the transfer becomes `voided` (left out of reconciliation,\nstatements and history totals; the R-transaction type is the\nreason). A hold the ledger released at its timeout (90 days) is\nrecorded `voided` / `SETTLED_EXPIRED` with an alert for operations.\nThe generic routes leave a hold alone: `POST\n/api/v1/transfers/{transferId}/cancel` is 409 `held_direct_debit`,\nthe hold routes answer it like an unknown hold. Without the flag (no\nflag row is off) the credit is posted at once and the hold is a\nrecord only, exactly as before; a flag that cannot be read refuses a\ndirect debit credit with 503 `holding_period_unavailable`.\n"
    },
    {
      "name": "TransactionMappings",
      "description": "ISO 20022 transaction code to General Ledger account mapping\n(BR-EF-012). Maps BankTransactionCodes (Domain/Family/SubFamily) to\ntarget accounts and posting directions. Resolution hierarchy:\ncustomer-specific overrides take precedence over tenant defaults,\nwhich take precedence over global mappings. Unmapped codes route to\na suspense account and enter the manual review queue.\n"
    },
    {
      "name": "Postings",
      "description": "Automated posting audit trail and manual review queue (BR-EF-012).\nEvery automated posting is recorded with the source transaction code,\nmapping rule applied, and result status. Items flagged as\nMANUAL_REVIEW can be resolved (assigned to a target account) or\nrejected by an admin.\n"
    },
    {
      "name": "Safeguarding",
      "description": "Client-funds safeguarding (BR-EF-034); for Art. 1b institutions\nthe cap on accepted public deposits.\nRegistry of safeguarding accounts with four-eyes approval, daily\nstatement import (CSV or camt.053 CLBD), and a reconciliation of\nrelevant funds (live, from the ledger) against the safeguarded balance.\nStaff (bank_admin, cfo, coo, auditor, super_admin) and service callers\nonly; customer tokens are refused. Every route requires X-Tenant-ID.\n"
    },
    {
      "name": "Reconciliation",
      "description": "Bank reconciliation with automated T+1 scheduling and manual trigger.\nImports CAMT.053 statements (ISO 20022 XML) and matches entries\nagainst ledger metadata using confidence scoring: exact match,\namount-only, reference-only, partial, and duplicate detection.\nBank operations personnel can manually match entries, investigate\ndiscrepancies, reject irrelevant items, approve statements, and\nre-run matching with relaxed tolerance. Built for safeguarding\nreconciliation.\n"
    },
    {
      "name": "Jurisdictions",
      "description": "Multi-jurisdiction regulatory profile management (BR-EF-014).\nEach jurisdiction defines retention periods, holiday calendars,\nchart-of-accounts mappings, and business day calculations.\nEach profile carries the rules of its country.\n"
    },
    {
      "name": "Integration",
      "description": "Provider abstraction for payments, IBAN generation, and virtual\naccount provisioning. IBANs follow country-specific formats for 12\ncountries with ISO 13616 check digit validation. Durable\nexecution endpoints handle long-running workflows (account opening\nwith IBAN assignment, payment orchestration) with automatic retry\nand compensation on failure.\n"
    },
    {
      "name": "Webhooks",
      "description": "Outbox-based webhook delivery. Events are written to the database\nbefore any delivery attempt, so nothing gets lost (at-least-once).\nFailed deliveries retry with exponential backoff. Payloads include\nthe event type and full resource state at the time of emission.\n"
    },
    {
      "name": "EddReview",
      "description": "Enhanced due diligence after a confirmed PEP match (migration 294):\nthe review a confirmation opens (risk level high, ongoing screening),\nits checklist (source of wealth, source of funds, senior management\napproval), documents of the customer's CDD register, notes and\nhistory, and a decision by a second officer of the bank. The bank's\nMLRO works and decides; the auditor and the platform read.\n"
    },
    {
      "name": "IctRisk",
      "description": "ICT risk records of a bank (DEC-0044): the ICT incident register\n(classification, reporting deadlines, reports sent, root cause and\nresolution, append-only timeline) and the ICT third-party\nregister.\nStaff sessions of the bank; the platform reads.\n"
    },
    {
      "name": "Audit",
      "description": "Immutable, hash-chained audit trail designed to support incident\ninvestigation, forensic reconstruction, and operational resilience\nevidence (FINMA Circular 2023/1 Operational\nrisks and resilience), subject to operational implementation and\nlegal validation.\nEach event is SHA-256 hash-chained to the previous one \u2014 tamper with any\nentry and the chain breaks. Events record entity type, entity ID, action,\nand actor. You can verify integrity by recomputing hashes from the start.\nRetention is at least the AML record-keeping period of the tenant's\njurisdiction. Between the append-only\nledger and this chain, there's a complete proof that no financial record\nwas altered after the fact.\n"
    },
    {
      "name": "Reports",
      "description": "WOFF/NPE reporting and aggregate statistics (BR-EF-015 Phase 5).\nWritten-off account summaries, recovery rates by IFRS 9 reason,\nand blocked transaction counts for operational risk reporting.\n"
    },
    {
      "name": "Beneficiaries",
      "description": "Saved payment beneficiary management (BR-EF-023). Customers maintain\na list of verified payees (IBAN or account number + routing number).\nAfter creation each beneficiary is automatically screened against the\nconfigured sanctions provider (BR-EF-026). Verification status tracks\nthe result of micro-deposit or bank validation checks.\n"
    },
    {
      "name": "Payees",
      "description": "Payees with several accounts (BR-EF-023 \u00a76.6, BR-FM-008). A payee is a\ncontact (party fields) with one or more accounts; each account has its\nown currency, scheme and bank, and one account per currency is the\ndefault. Stored in the beneficiary table (root row plus rows linked by\n`contact_id`), so `/api/v1/beneficiaries` keeps working unchanged.\nAccess and error codes are the beneficiary ones, plus 409\n`last_account`, 409 `payee_changed` and 400 `invalid_scheme`.\n"
    },
    {
      "name": "KAM",
      "description": "Key Account Manager assignment CRUD (BR-AP-021). Maps KAM users to\ncustomers within a tenant. The scoping check endpoint lets the portal\nenforce data access control \u2014 a KAM can only access customers they\nare explicitly assigned to.\n"
    },
    {
      "name": "Approvals",
      "description": "Transfer approval workflow for transactions that exceed configured\nlimit thresholds (F-02). Implements the 4-eyes principle: the\nreviewer must differ from the original requester. Approved transfers\nare durably executed via the workflow engine.\nPending approvals auto-expire via delayed workflow invocation.\n"
    },
    {
      "name": "Stats",
      "description": "Admin dashboard aggregate statistics (F-12). KPI overview includes\ncustomer counts by status, transfer volume (today and month-to-date),\nKYC session stats, and pending approvals count. Time-series endpoint\nsupports daily and monthly granularity with optional custom date ranges.\n"
    },
    {
      "name": "LedgerReadOnlyInspection",
      "description": "Read-only ledger engine inspection endpoints. Allow bank operations\nand engineering staff to query accounts and transfers directly from the\nledger engine without going through the business-logic layer. All\nendpoints are GET only; no writes are permitted through this interface.\nFor audit purposes, treat as a restricted read-only operational interface.\n"
    },
    {
      "name": "ComplianceRules",
      "description": "Officer-visible compliance rule catalogue (BR-EF-033). This is the book,\nnot the payment evaluator. `finance_tm_rule` stays the native TM engine.\nNew rows are inventory with no engine. Hold is rejected. Inventory MUST NOT fire.\nRestricted to mlro and super_admin roles.\n"
    },
    {
      "name": "SAR",
      "description": "Suspicious Activity Reports to the national Financial Intelligence Unit\n(Switzerland: reports to MROS, AMLA Art. 9).\nMLRO-confidential \u2014 never exposed to the customer portal. SARs are created as\ndrafts, edited, then submitted as immutable records. Exports produce structured\nJSON for manual filing with the Financial Intelligence Unit (FIU). Access\nrestricted to mlro and super_admin roles.\n"
    },
    {
      "name": "KYBCases",
      "description": "AI-assisted KYB (Know Your Business) verification cases (BR-EF-013).\nThe KybAiWorkflow drives automated document extraction and UBO\nscreening. MLRO reviews AI-extracted entities and records a final\napprove/reject/escalate decision. Internal status transitions are driven\nby the workflow via X-Service-Key authentication; MLRO decisions require\nthe mlro role.\n"
    },
    {
      "name": "Observability",
      "description": "Prometheus-compatible metrics endpoint (ARCH-021, SF-observability-stack).\nExposes atomic counters for requests, errors, wallet events, KYC outcomes,\ntransfers, and screening hits in Prometheus text exposition format.\nSuitable for scraping by Prometheus, Grafana Agent, or any\nOpenMetrics-compatible collector. No JWT authentication required \u2014 restrict\naccess at the network or proxy layer.\n"
    },
    {
      "name": "Statements",
      "description": "Monthly account statement records for the customer Documents area. Records\nare created per wallet per period by the MonthlyStatementScheduler workflow,\npopulated with balances and an S3 object key by the MonthlyStatementGeneration\nworkflow, and read by the customer portal. Workflow-driven endpoints use\nX-Service-Key authentication; read endpoints are tenant-isolated via RLS.\n"
    },
    {
      "name": "Documents",
      "description": "Customer documents generated by finance-api (DEC-0030): account\nstatements (PDF, CSV, camt.053.001.08, MT940), a statement summary for\npreviews, the export of a filtered transaction list (CSV, PDF), the\ntransfer confirmation PDF and the account confirmation letter. One\ngenerator: web and mobile download the same bytes. All reads; a\ncustomer JWT reaches its own customer, accounts and transfers only\n(accounting and read-only sessions included). At most two document\nrequests per customer at once (`429 busy`). Errors are\n`{\"error\":{\"code\":\"...\",\"message\":\"...\"}}`.\n"
    },
    {
      "name": "Letters",
      "description": "Durable-medium letters from the bank (DEC-0033 decision 11, ARCH-030\n\u00a79): an immutable PDF for each request\nwith a consequence, a change of its due date and a complaint\nwithdrawal, generated once by finance-api, stored with Object Lock\n(COMPLIANCE) and served as stored, with its SHA-256 in\n`X-Letter-SHA256`. A change is a new letter that supersedes the old\none. The e-mail only says a letter is there. Customer JWT for the own\ncustomer (also with `support_tickets` off) and staff of the tenant\n(`bank_admin`, `auditor`: every customer; the other support roles:\ncustomers of cases they may see; audited `support.letter.viewed`).\nErrors are `{\"error\":{\"code\":\"...\",\"message\":\"...\"}}`.\n"
    },
    {
      "name": "Support",
      "description": "Customer support thread (DEC-0032, contract ARCH-029a): one thread per\ncustomer profile, an AI first line when the tenant switches\n`support_ai` on, a person on request at any time. Customer JWT only;\nimpersonation sessions read only. Poll `GET /support/thread` with\n`If-None-Match`. AI answers carry `ai_generated` and `ai_disclosure`;\nthe thread carries `disclosure_required`. Tenant feature\n`support_chat` off: 404 `support_disabled`. Errors are\n`{\"error\":{\"code\":\"...\",\"message\":\"...\"}}`.\n"
    },
    {
      "name": "SupportTickets",
      "description": "Customer tickets (DEC-0033, contract ARCH-030 \u00a75): the customer's\nRequests area. A customer may hold any number of tickets, opened by\nthe customer (topic form) or by the bank (typed requests: answer,\ndocuments, confirm). Customer JWT only, own profile; impersonation\nsessions read only (403 `read_only_session` on every write). A ticket\nof another customer or tenant is 404 `not_found`. Tenant feature\n`support_tickets` off: 404 `tickets_disabled` (independent of\n`support_chat`); `GET /support/summary` answers with either feature\noff. Poll with `If-None-Match`. No AI on tickets:\n`disclosure_required` is false and every message has\n`ai_generated: false`. No answer names an internal classification or\nteam of the bank. Errors are `{\"error\":{\"code\":\"...\",\"message\":\"...\"}}`.\n"
    },
    {
      "name": "SupportDesk",
      "description": "Core-Bank support desk (BR-AP-024): inbox, cases, replies, notes,\ntasks, assignment, escalation, classification, complaint holding and\nfinal replies, the complaint register and the SAC annual report.\nAdmin session; tenant from the session; roles `support_agent`,\n`support_lead`, `sac_officer`, `mlro`, `risk_officer`, `bank_admin`,\n`auditor` (ARCH-029a \u00a712, ARCH-030 \u00a713). A case the role may not see\nis 404. Every case view is audited (`support.case.viewed`, purpose\n`customer_support`). Tickets (DEC-0033, ARCH-030 \u00a76): a ticket is a\ncase of kind `ticket` with its own conversation; `POST\n/support/cases` with `kind: ticket`, typed requests, review, resolve\nwith a resolution, cancel.\n"
    },
    {
      "name": "SupportConfig",
      "description": "Support configuration per tenant: queues, SLA policies, the business\ncalendar, macros, help articles, support settings and AI settings\n(ARCH-029a \u00a76). Admin session. Tickets (ARCH-030 \u00a76.9, \u00a76.12):\nrequest templates with four eyes and legal counsel's approval for\n`aml_rfi`, and the customer topics.\n"
    },
    {
      "name": "SupportInternal",
      "description": "Service routes for the workflows service (Restate `Assistant.support_turn`,\n`SupportCase`, `SupportNotify`, `SupportRetentionScheduler`;\nARCH-029a \u00a77, \u00a710). `X-Service-Key` and `X-Tenant-ID`, and with\n`SUPPORT_INTERNAL_KEY` configured also `X-Support-Internal-Key`\n(ARCH-029a \u00a77.0): the shared service key is held by identity-api too,\nso these routes take a key only the workflows service holds; without\nit 403 `support_key_required`. Responses carry ids, hashes and\ntokenised text; never call from a client.\n"
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "operationId": "getHealth",
        "tags": ["Health"],
        "summary": "Liveness check",
        "responses": {
          "200": {
            "description": "Service is healthy",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "example": "ok"
                    },
                    "version": {
                      "type": "string",
                      "example": "0.26.0"
                    },
                    "service": {
                      "type": "string",
                      "example": "isaac-finance"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/ready": {
      "get": {
        "operationId": "getReady",
        "tags": ["Health"],
        "summary": "Readiness check (ledger + database)",
        "description": "Ready when the database answers and holds the schema this build reads\n(`schema`: migration 294, `finance_edd_review`). A build deployed\nbefore its migration answers 503 `not_ready` instead of refusing\ncustomers.\n",
        "responses": {
          "200": {
            "description": "Service is ready",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": ["ready", "not_ready"]
                    },
                    "ledger": {
                      "type": "boolean"
                    },
                    "database": {
                      "type": "boolean"
                    },
                    "schema": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service not ready (database down or schema missing)"
          }
        }
      }
    },
    "/openapi.json": {
      "get": {
        "operationId": "getOpenApiSpec",
        "tags": ["Health"],
        "summary": "OpenAPI 3.0 specification",
        "responses": {
          "200": {
            "description": "OpenAPI JSON specification"
          }
        }
      }
    },
    "/api/v1/auth/login": {
      "post": {
        "operationId": "login",
        "tags": ["Auth"],
        "summary": "Authenticate admin user",
        "description": "Authenticates an admin user with email and password. If MFA is enabled\nfor the user, returns a partial session requiring TOTP verification\nvia `POST /api/v1/auth/mfa/verify` before full access is granted.\nAccount lockout is enforced after 5 consecutive failed attempts\n(OWASP brute-force protection). Passwords are verified against\nArgon2id hashes (OWASP recommended).\n\n`audience` (SF-support-desk-isolation) names the console the session\nis for: `core` (Core-Bank, the default) or `desk` (the support desk,\ne.g. a desk-only build for an external contact centre). A `desk`\nsession reaches only the support desk routes (`/api/v1/support/**`\nand the few reads the desk needs); every other `/api/v1` route\nanswers 403 `forbidden_audience`, whatever the role or cell policy.\nThe audience is fixed for the life of the session. A request through\nthe desk edge (header `X-Fernel-Desk-Edge` equal to the server's\n`DESK_EDGE_SECRET`) always gets a `desk` session; `audience: core`\nfrom it is 400, and a core session is refused on every route from\nit (403 `forbidden_audience`). `audience` of any other JSON type\nthan a string is 400. A desk session in the platform scope (after a\ncell switch to the platform) reaches no route. An edge header that\ndoes not match, or a service key through the edge, is 403 on every\nroute; a request with more than 64 headers or 16 KB of header data\nis 431.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["email", "password"],
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "password": {
                    "type": "string",
                    "format": "password"
                  },
                  "audience": {
                    "type": "string",
                    "enum": ["core", "desk"],
                    "default": "core",
                    "description": "The console the session is for; anything else is 400"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Login successful or MFA required",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "requiresMfa": {
                      "type": "boolean"
                    },
                    "password_change_required": {
                      "type": "boolean",
                      "description": "The account was created, or its password reset, by\nanother operator (migration 272). The operator sets an\nown password with `POST /api/v1/auth/password/change`\nbefore MFA is accepted: for every staff role\n`/mfa/verify` and `/mfa/confirm` answer 403\n`password_change_required` until then, and a session\nthat passed MFA while the flag is still set is ended\n(401) on its next call.\n"
                    },
                    "sessionToken": {
                      "type": "string"
                    },
                    "aud": {
                      "type": "string",
                      "enum": ["core", "desk"],
                      "description": "The session's audience (the requested one)"
                    },
                    "user": {
                      "$ref": "#/components/schemas/AdminUser"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing email or password, or `audience` other than core or desk"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "423": {
            "description": "Account locked (too many failed attempts)"
          }
        }
      }
    },
    "/api/v1/auth/logout": {
      "post": {
        "operationId": "logout",
        "tags": ["Auth"],
        "summary": "Invalidate session and revoke access",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Logged out"
          }
        }
      }
    },
    "/api/v1/auth/session": {
      "get": {
        "operationId": "getSession",
        "tags": ["Auth"],
        "summary": "Retrieve current session state",
        "description": "Returns the authenticated user's session details including remaining\nTTL and inactivity warning flag. The `inactivity_warning` field is\nset to `true` when less than 5 minutes remain, allowing the client\nto prompt for session extension before automatic expiry.\n`session.aud` is the session's audience (`core` or `desk`); a session\nwritten before the field reads as `core`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "403": {
            "description": "`{\"error\":\"role_changed\"}`: the operator's role changed since login"
          },
          "503": {
            "description": "`{\"error\":\"session_check_unavailable\"}`: Redis or the database could not confirm the session; the session is kept"
          },
          "200": {
            "description": "Session details",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "user": {
                      "$ref": "#/components/schemas/AdminUser"
                    },
                    "session": {
                      "type": "object",
                      "description": "The stored staff session (scope, cell, policy, ...)",
                      "properties": {
                        "aud": {
                          "type": "string",
                          "enum": ["core", "desk"],
                          "default": "core",
                          "description": "The console the session was made for. `desk`: only\nthe support desk routes; every other `/api/v1`\nroute answers 403 `forbidden_audience`.\n"
                        }
                      }
                    },
                    "expires_in": {
                      "type": "integer",
                      "description": "Seconds until expiry"
                    },
                    "inactivity_warning": {
                      "type": "boolean",
                      "description": "True when < 5 min remaining"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/v1/auth/refresh": {
      "post": {
        "operationId": "refreshSession",
        "tags": ["Auth"],
        "summary": "Refresh session token",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "401": {
            "description": "Session revoked, operator disabled or demoted, or cell membership withdrawn (the session ends)"
          },
          "503": {
            "description": "`{\"error\":\"session_check_unavailable\"}`: Redis or the database could not confirm the session; the session is kept"
          },
          "200": {
            "description": "New session token"
          }
        }
      }
    },
    "/api/v1/auth/mfa/verify": {
      "post": {
        "operationId": "mfaVerify",
        "tags": ["Auth"],
        "summary": "Verify MFA TOTP code (RFC 6238)",
        "description": "A code is accepted once: the same code is refused for the rest of its\n30-second step (`code_already_used`). Five wrong codes end the\nsession (`too_many_attempts`, log in again). Wrong codes lock the\naccount from the fifth on, 60 s doubling per failure up to 1 h\n(429 `mfa_locked` with `retry_after` seconds).\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["session_token", "code"],
                "properties": {
                  "session_token": {
                    "type": "string"
                  },
                  "code": {
                    "type": "string",
                    "minLength": 6,
                    "maxLength": 6
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "MFA verified, full session issued"
          },
          "401": {
            "description": "Invalid code, `code_already_used`, `too_many_attempts` or unknown session"
          },
          "429": {
            "description": "`mfa_locked`, body {\"error\":\"mfa_locked\",\"retry_after\":<seconds>}"
          }
        }
      }
    },
    "/api/v1/auth/mfa/setup": {
      "post": {
        "operationId": "mfaSetup",
        "tags": ["Auth"],
        "summary": "Initialise MFA enrolment (TOTP secret + QR URI)",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "401": {
            "description": "No current session (revoked, disabled or expired)"
          },
          "403": {
            "description": "`{\"error\":\"role_changed\"}`: the operator's role changed since login"
          },
          "503": {
            "description": "`{\"error\":\"session_check_unavailable\"}`: Redis or the database could not confirm the session; the session is kept"
          },
          "200": {
            "description": "TOTP setup data"
          }
        }
      }
    },
    "/api/v1/auth/mfa/confirm": {
      "post": {
        "operationId": "mfaConfirm",
        "tags": ["Auth"],
        "summary": "Confirm MFA enrolment with TOTP verification code",
        "description": "Stores the TOTP secret from `/mfa/setup` once `code` verifies against\nit. The session in the Authorization header is the one enrolled; a\nbody `sessionToken` must name the same session. The first enrolment\nneeds `enrolment_token`: a one-time token (1 h, single use) issued out\nof band by a platform super-admin (`/users/{id}/enrolment-token`,\n`/users/{id}/reset-mfa`) or by `make admin-enrolment-token`.\nReplacing an enrolled authenticator needs an MFA-verified session\ninstead. On success the session becomes MFA-verified (a password\nlogin alone never does).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["secret", "code"],
                "properties": {
                  "secret": {
                    "type": "string"
                  },
                  "code": {
                    "type": "string"
                  },
                  "sessionToken": {
                    "type": "string"
                  },
                  "enrolment_token": {
                    "type": "string",
                    "pattern": "^[0-9a-f]{64}$",
                    "description": "Required for the first enrolment."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "503": {
            "description": "`{\"error\":\"session_check_unavailable\"}`: Redis or the database could not confirm the session; the session is kept"
          },
          "200": {
            "description": "MFA enabled; the session is MFA-verified"
          },
          "401": {
            "description": "Invalid code, unknown session, session mismatch or `too_many_attempts`"
          },
          "403": {
            "description": "`enrolment_token_required`, `enrolment_token_invalid`, or MFA already enrolled and the session is not MFA-verified"
          }
        }
      }
    },
    "/api/v1/auth/cells": {
      "get": {
        "operationId": "listMyCells",
        "tags": ["Auth"],
        "summary": "The operator's cells and the active scope (DEC-0017)",
        "description": "Cells (regulated installations) the operator is linked to through\n`admin_cell_membership`, with their tenants, and the scope of this\nsession. Inside a cell every `/api/v1` request runs on the session's\n`tenant_id`: `X-Tenant-ID` may only repeat it (else 403\n`tenant_mismatch`) and may be omitted. Needs an MFA-verified session.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "503": {
            "description": "`{\"error\":\"session_check_unavailable\"}`: Redis or the database could not confirm the session; the session is kept"
          },
          "200": {
            "description": "Cells and active scope",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "active": {
                      "$ref": "#/components/schemas/StaffScope"
                    },
                    "platform_allowed": {
                      "type": "boolean",
                      "description": "The account is a super_admin (may switch to the platform scope)."
                    },
                    "cells": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "cell_id": {
                            "type": "string",
                            "example": "airis-es"
                          },
                          "jurisdiction": {
                            "type": "string",
                            "example": "ES"
                          },
                          "label": {
                            "type": "string"
                          },
                          "policy": {
                            "type": "string",
                            "description": "Role inside the cell (admin_role)"
                          },
                          "tenants": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "tenant_id": {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                "name": {
                                  "type": "string"
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "No or expired session"
          },
          "403": {
            "description": "MFA verification required"
          }
        }
      }
    },
    "/api/v1/auth/cells/switch": {
      "post": {
        "operationId": "switchCell",
        "tags": ["Auth"],
        "summary": "Change the session's active cell and tenant (DEC-0017)",
        "description": "Only among the operator's own active memberships, re-read from the\ndatabase. `{\"cell_id\":\"platform\"}` selects the explicit platform\nscope (super_admin accounts only), which platform actions (tenant\nlifecycle, API keys, OAuth clients, branding, staff IAM, audit chain)\nrequire. Tenant features are the bank's own admin's as well (DEC-0031). Needs an MFA-verified session. Audited as\n`AUTH_CELL_SWITCH`. The session token stays the same.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["cell_id"],
                "properties": {
                  "cell_id": {
                    "type": "string",
                    "example": "airis-es"
                  },
                  "tenant_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "A tenant of that cell; default its first tenant."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "503": {
            "description": "`{\"error\":\"session_check_unavailable\"}`: Redis or the database could not confirm the session; the session is kept"
          },
          "200": {
            "description": "New active scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StaffScope"
                }
              }
            }
          },
          "400": {
            "description": "Missing cell_id or tenant_id not a UUID"
          },
          "403": {
            "description": "Not a member of that cell or tenant, platform asked by a non-super-admin, or MFA not verified"
          }
        }
      }
    },
    "/api/v1/auth/users/{userId}/memberships": {
      "get": {
        "operationId": "listOperatorMemberships",
        "tags": ["Auth"],
        "summary": "An operator's cell links with the banks of each cell (platform super_admin)",
        "description": "Active links first, then revoked ones (kept with who revoked them and\nwhen). Card SF-cell-membership-admin-api, migration 283.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{user_id, memberships: [CellMembership]}`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "user_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "memberships": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CellMembership"
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Not a platform-scope super_admin staff session with MFA"
          }
        }
      },
      "post": {
        "operationId": "grantOperatorMembership",
        "tags": ["Auth"],
        "summary": "Give an operator a policy in a bank's cell (platform super_admin)",
        "description": "A super_admin staff session in the platform scope (never a service\nkey acting for an operator). The policy is any staff role but\n`super_admin`. `bank_admin` and `mlro` are four-eyes requests (202\n`pending_approval`, actions `staff_grant_bank_admin`,\n`staff_grant_mlro`): another super_admin approves, never the\nrequester and never the operator concerned. Nobody grants access to\nthemselves; a suspended or deactivated account gets none. The\nchecks run again with the operator row locked. A link to a cell of\nanother jurisdiction than the operator's other active links is\nrefused (409 `jurisdiction_conflict`, migration 181). A grant writes\n`STAFF_CELL_ACCESS_GRANTED` (platform audit) and `staff.access.granted`\n(each bank of the cell) in the same transaction, re-opens a revoked\nrow of the same cell, and ends the operator's sessions before it\ncommits (503 `sessions_unavailable` and nothing changes when the\nsession store does not take it).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["tenant_id", "policy", "reason"],
                "properties": {
                  "tenant_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "The bank; the link is to its cell."
                  },
                  "policy": {
                    "type": "string",
                    "example": "support_lead"
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 10,
                    "maxLength": 1000,
                    "description": "10 to 1000 characters after trimming; the link covers every bank of the cell"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`{status: granted, membership}`"
          },
          "202": {
            "description": "`{status: pending_approval, approval: PlatformApproval}` (bank_admin, mlro)"
          },
          "400": {
            "description": "`reason_required`, `invalid_field`"
          },
          "403": {
            "description": "`self_grant`, `forbidden_role`"
          },
          "404": {
            "description": "No such operator"
          },
          "409": {
            "description": "`bank_without_cell`, `jurisdiction_conflict`, `already_granted`, `operator_deactivated`, `operator_suspended`, `approval_pending`"
          },
          "422": {
            "description": "`policy_not_allowed` (super_admin)"
          },
          "503": {
            "description": "`audit_unavailable`, `sessions_unavailable`: nothing changed"
          }
        }
      }
    },
    "/api/v1/auth/users/{userId}/memberships/{cellId}/revoke": {
      "post": {
        "operationId": "revokeOperatorMembership",
        "tags": ["Auth"],
        "summary": "End an operator's link to a cell (platform super_admin)",
        "description": "The row stays (`revoked_at`, `revoked_by`). Writes\n`STAFF_CELL_ACCESS_REVOKED` and `staff.access.revoked` in the same\ntransaction and ends the operator's sessions. A reason of 10 to 1000\ncharacters.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "cellId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9][a-z0-9-]{1,62}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["reason"],
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 10,
                    "maxLength": 1000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`{status: revoked, membership}`"
          },
          "400": {
            "description": "`reason_required`, `invalid_field`"
          },
          "404": {
            "description": "No such operator, cell or link"
          },
          "409": {
            "description": "`not_active` (already revoked)"
          },
          "503": {
            "description": "`audit_unavailable`: nothing changed"
          }
        }
      }
    },
    "/api/v1/auth/memberships": {
      "get": {
        "operationId": "listBankMembers",
        "tags": ["Auth"],
        "summary": "The members of a bank's cell (platform super_admin)",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "include_revoked",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{cell: {id, label, jurisdiction} | null, members: [...]}`"
          },
          "400": {
            "description": "`invalid_field`"
          }
        }
      }
    },
    "/api/v1/auth/cells/catalog": {
      "get": {
        "operationId": "listCellCatalog",
        "tags": ["Auth"],
        "summary": "Every cell with its banks (platform super_admin; bank onboarding)",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "`{cells: [{cell_id, label, jurisdiction, banks: [{tenant_id, name, status}]}]}`"
          }
        }
      }
    },
    "/api/v1/auth/users/{userId}/enrolment-token": {
      "post": {
        "operationId": "issueEnrolmentToken",
        "tags": ["Auth"],
        "summary": "One-time TOTP enrolment token for an operator, mailed to the operator (platform super_admin)",
        "description": "Mailed to the operator's own e-mail address through identity-api\n(`POST /api/v1/internal/staff-mail`), never answered to the issuing\nsuper-admin (review H1). Valid 1 hour, single use; earlier unused\ntokens of the operator are voided. Audited as\n`AUTH_MFA_ENROL_TOKEN_ISSUED` in the same transaction; a mail that\ncannot be sent is 503 `mail_unavailable` and nothing changes.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Token issued",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "user_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "enrolment_token": {
                      "type": "string",
                      "pattern": "^[0-9a-f]{64}$"
                    },
                    "expires_at": {
                      "type": "integer",
                      "description": "Unix seconds"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Not a platform-scope super_admin session with MFA"
          },
          "404": {
            "description": "No active operator with that id"
          },
          "409": {
            "description": "`mfa_already_enabled` (use reset-mfa)"
          }
        }
      }
    },
    "/api/v1/auth/users/{userId}/reset-mfa": {
      "post": {
        "operationId": "resetAdminMfa",
        "tags": ["Auth"],
        "summary": "Clear an operator's authenticator and mail an enrolment token (platform super_admin)",
        "description": "Clears the TOTP secret, the failure counter, lock and last used step,\nand mails a fresh one-time enrolment token to the operator's own\ne-mail (never to the resetting super-admin, review H1). A reason of 10\nto 1000 characters is required (`{reason}`, 400 `reason_required`). A\nsuper_admin's MFA is reset only on a second\nsuper_admin's approval: 202 `pending_approval` (`staff_reset_mfa`).\nAudited as `AUTH_MFA_RESET` in the same transaction; not for one's own\naccount (409 `own_account`); a mail that cannot be sent is 503\n`mail_unavailable` and nothing changes.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["reason"],
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 10,
                    "maxLength": 1000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The user, with `credential_delivery: email` (no token); 202 `{status: pending_approval, approval}` for a super_admin"
          },
          "400": {
            "description": "`reason_required` (10 to 1000 characters)"
          },
          "404": {
            "description": "User not found"
          }
        }
      }
    },
    "/api/v1/auth/users/{userId}/unlock": {
      "post": {
        "operationId": "unlockAdminUser",
        "tags": ["Auth"],
        "summary": "End an operator's sign-in lock before its time (platform super_admin)",
        "description": "The failed sign-ins go back to zero and the lock ends now. A reason of\n10 to 1000 characters is required; it is written into the\n`STAFF_UNLOCKED` platform audit row in the same transaction.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["reason"],
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 10,
                    "maxLength": 1000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The user"
          },
          "400": {
            "description": "`reason_required` (10 to 1000 characters)"
          },
          "404": {
            "description": "User not found"
          },
          "503": {
            "description": "`audit_unavailable`: nothing changed"
          }
        }
      }
    },
    "/api/v1/auth/users/{userId}/reset-password": {
      "post": {
        "operationId": "resetAdminPassword",
        "tags": ["Auth"],
        "summary": "Mail an operator a temporary password (platform super_admin)",
        "description": "A new temporary password, mailed to the operator's own e-mail and\nnever answered to the resetting super_admin (review H1). The account\nis unlocked, its sessions end, and the operator must change the\npassword before MFA is accepted (`password_change_required`). A reason\nof 10 to 1000 characters is required; the reset and its `STAFF_PASSWORD_RESET` platform audit\nrow are one transaction. A super_admin's password is reset only on a\nsecond super_admin's approval: 202 `pending_approval`\n(`staff_reset_password`). Not for one's own account (409\n`own_account`); a mail that cannot be sent is 503 `mail_unavailable`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["reason"],
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 10,
                    "maxLength": 1000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The user, with `credential_delivery: email` (no password); 202 `{status: pending_approval, approval}` for a super_admin"
          },
          "400": {
            "description": "`reason_required`"
          },
          "404": {
            "description": "User not found"
          },
          "409": {
            "description": "`own_account`"
          },
          "503": {
            "description": "`audit_unavailable`: nothing changed"
          }
        }
      }
    },
    "/api/v1/auth/password/change": {
      "post": {
        "operationId": "changeOwnPassword",
        "tags": ["Auth"],
        "summary": "Change one's own password (a change due before MFA, otherwise after MFA)",
        "description": "The operator's own password. With a session before MFA only while the\naccount has a password change due (`password_change_required`: a new\naccount or a reset); otherwise the session must have passed MFA (403\n`mfa_required`). A locked account is 429 `account_locked` with\n`retry_after`, as at sign-in. The current password is checked (a wrong\none counts as a failed sign-in); the new one has 12 to 128 characters\nand differs from it. Clears `password_change_required` and the failed\nsign-ins; the change and its `AUTH_PASSWORD_CHANGED` platform audit row\nare one transaction, written only if the account is still the one\nchecked (else 409 `password_conflict`, nothing changed).\n\nEvery session of the operator then ends, the calling one included. The\nanswer carries a new `session_token` for the caller (same scope,\naudience and MFA state); the old token is gone. When the session store\ncannot issue one, the answer says `sign_in_again: true` instead.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["current_password", "new_password"],
                "properties": {
                  "current_password": {
                    "type": "string",
                    "format": "password"
                  },
                  "new_password": {
                    "type": "string",
                    "format": "password",
                    "minLength": 12,
                    "maxLength": 128
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`{success: true, password_change_required: false, session_token}`, or `sign_in_again: true` without a token"
          },
          "400": {
            "description": "`current_password_required`, `new_password_required`, `password_length` or `password_unchanged`"
          },
          "401": {
            "description": "Invalid credentials"
          },
          "403": {
            "description": "`mfa_required`: a session before MFA, and no password change due"
          },
          "409": {
            "description": "`password_conflict`: the account changed meanwhile; nothing changed"
          },
          "429": {
            "description": "`account_locked` with `retry_after` (seconds)"
          },
          "503": {
            "description": "`audit_unavailable`: nothing changed"
          }
        }
      }
    },
    "/api/v1/auth/users": {
      "get": {
        "operationId": "listAdminUsers",
        "tags": ["Auth"],
        "summary": "List admin users",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Admin users list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "users": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/AdminUser"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createAdminUser",
        "tags": ["Auth"],
        "summary": "Create admin user (requires super_admin role)",
        "description": "A new operator in `pending` status. No operator chooses or sees the\nfirst password: finance-api generates it and mails it to the account's\nown e-mail (identity-api staff mail); it is never in the answer. The\noperator changes it at the first sign-in, before MFA is accepted\n(`password_change_required`). The account, its `STAFF_CREATED` platform\naudit row and the mail are one transaction: a mail that cannot be sent\nis 503 `mail_unavailable` and nothing is created.\n\n`role: super_admin` is a four-eyes request instead (Super-Admin audit\n2026-10-06): `reason` (10 to 1000 characters) is required, the\nanswer is 202 `pending_approval`, and the account is created, in\n`pending` status, when another super_admin approves it\n(`POST /api/v1/platform/approvals/{id}/approve`); its temporary\npassword then goes to the account's own e-mail in the same way,\nnever into the answer. Once a super_admin activates the account, the\nnew super_admin signs in, changes the temporary password and sets up\nMFA with an enrolment code sent to that e-mail.\n\n`tenant_id` (optional, not for super_admin) names the institution\nthe operator is created for: the first-password mail carries its\nname. Without it the mail carries the creator's own institution, or\nthe platform's name when the creator has none. It grants no access:\nthat stays a cell membership (`/api/v1/auth/users/{id}/memberships`).\nIt is recorded in the `STAFF_CREATED` audit row.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["email", "name", "role"],
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email",
                    "maxLength": 254
                  },
                  "password": {
                    "type": "string",
                    "format": "password",
                    "deprecated": true,
                    "description": "Ignored and deprecated: the first password is generated and mailed to the account (W6 decision 2). Older clients may still send it."
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "role": {
                    "$ref": "#/components/schemas/AdminRole"
                  },
                  "reason": {
                    "type": "string",
                    "maxLength": 1000,
                    "description": "Required for super_admin (10 to 1000 characters); recorded in the audit row"
                  },
                  "tenant_id": {
                    "type": ["string", "null"],
                    "format": "uuid",
                    "description": "The institution the operator is created for (finance_tenant id): the first-password mail carries its name. Ignored for super_admin. Missing, null or empty: the creator's institution, or the platform."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "User created; the first password was mailed to the account (never in the answer)"
          },
          "202": {
            "description": "super_admin: `{status: pending_approval, approval}`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlatformApprovalPending"
                }
              }
            }
          },
          "400": {
            "description": "`validation_error` with `field` (a name over 200 characters or an e-mail over 254, the limits of the credential mail), `reason_required` (super_admin), `invalid_tenant` (`tenant_id` is not a UUID), `unknown_tenant` (no institution has this `tenant_id`), or an invalid e-mail, name or role"
          },
          "409": {
            "description": "`email_taken`, `approval_pending`, `tenant_terminated` (the `tenant_id` institution is terminated) or a duplicate e-mail"
          },
          "503": {
            "description": "`mail_unavailable`: the first password could not be mailed, nothing was created; `audit_unavailable`: nothing changed"
          }
        }
      }
    },
    "/oauth/token": {
      "post": {
        "operationId": "issueOAuthToken",
        "tags": ["OAuth"],
        "summary": "Issue access token (OAuth2 Client Credentials, RFC 6749 S4.4)",
        "description": "Implements the OAuth2 Client Credentials grant type for machine-to-machine\nAPI access. Validates the `client_id` and `client_secret` against stored\ncredential hashes, verifies the credential is active and not expired, and\nissues a time-limited JWT access token scoped to the credential's\npermission set. Token lifetime is configurable (default 3600 seconds).\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["grant_type", "client_id", "client_secret"],
                "properties": {
                  "grant_type": {
                    "type": "string",
                    "enum": ["client_credentials"]
                  },
                  "client_id": {
                    "type": "string",
                    "example": "pd_test_abc123"
                  },
                  "client_secret": {
                    "type": "string",
                    "example": "sk_test_xyz789"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Access token issued",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "access_token": {
                      "type": "string"
                    },
                    "token_type": {
                      "type": "string",
                      "example": "Bearer"
                    },
                    "expires_in": {
                      "type": "integer",
                      "example": 3600
                    },
                    "scope": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid client credentials"
          }
        }
      }
    },
    "/verify": {
      "get": {
        "operationId": "verifyForwardAuth",
        "tags": ["OAuth"],
        "summary": "ForwardAuth token verification endpoint",
        "description": "Called by the API gateway on every upstream request to validate the\nBearer token and inject tenant context headers (`X-Tenant-ID`,\n`X-Tenant-Env`) into the forwarded request. Returns `200` with injected\nheaders on valid tokens; `401` causes the gateway to reject the\nupstream request. This enforces tenant isolation at the API gateway level.\n\nA tenant token names its credential (`cid`). The credential must be\nactive, not revoked or expired, of the token's bank, and the bank\nactive: a revoke, a rotation or a suspended or terminated bank refuses\ntokens already issued at once on the instance that made the change\nand within 5 seconds on any other. A token without `cid` (minted\nbefore this check) is refused. When the check cannot be made the\nanswer is `503` (fail closed).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Token valid (headers injected)",
            "headers": {
              "X-Tenant-ID": {
                "schema": {
                  "type": "string"
                }
              },
              "X-Tenant-Env": {
                "schema": {
                  "type": "string",
                  "enum": ["sandbox", "production"]
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired token, a revoked or rotated credential, or a bank that is not active"
          },
          "503": {
            "description": "`temporarily_unavailable`: the credential could not be checked"
          }
        }
      }
    },
    "/api/v1/credentials/{credentialId}/revoke": {
      "post": {
        "operationId": "revokeCredential",
        "tags": ["Credentials"],
        "summary": "Revoke OAuth2 credential (immediate invalidation)",
        "description": "Immediately invalidates the credential. All access tokens issued via\nthis credential are refused by `/verify` within 5 seconds. Use for\ncompromised credentials or tenant off-boarding.\nA super_admin staff session in the platform scope (not a service key\nacting for an operator), with a reason; audited in the same\ntransaction (`TENANT_API_CREDENTIAL_*`), never with the secret.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CredentialId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["tenant_id", "reason"],
                "properties": {
                  "tenant_id": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1000,
                    "description": "Recorded with the change (finance and platform audit rows)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Credential revoked"
          },
          "400": {
            "description": "`reason_required`"
          },
          "403": {
            "description": "`forbidden_role`"
          },
          "404": {
            "description": "No such credential of this bank"
          },
          "409": {
            "description": "`credential_revoked`, `tenant_terminated`"
          }
        }
      }
    },
    "/api/v1/credentials/{credentialId}/rotate": {
      "post": {
        "operationId": "rotateCredential",
        "tags": ["Credentials"],
        "summary": "Rotate credential (atomic revoke and reissue)",
        "description": "Atomically revokes the existing credential and issues a new\n`client_id` / `client_secret` pair. The new secret is returned once\nin the response. Enables zero-downtime key rotation when the tenant\nupdates their integration before the old credential expires.\nA super_admin staff session in the platform scope (not a service key\nacting for an operator), with a reason; audited in the same\ntransaction (`TENANT_API_CREDENTIAL_*`), never with the secret.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CredentialId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["tenant_id", "reason"],
                "properties": {
                  "tenant_id": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1000,
                    "description": "Recorded with the change (finance and platform audit rows)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "New credential (secret shown once)"
          },
          "400": {
            "description": "`reason_required`"
          },
          "403": {
            "description": "`forbidden_role`"
          },
          "404": {
            "description": "No such credential of this bank"
          },
          "409": {
            "description": "`credential_revoked`, `tenant_terminated`"
          }
        }
      }
    },
    "/api/v1/credentials/validate": {
      "post": {
        "operationId": "validateCredential",
        "tags": ["Credentials"],
        "summary": "Validate credential existence and status",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["client_id"],
                "properties": {
                  "client_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Credential valid"
          },
          "401": {
            "description": "Invalid credentials"
          }
        }
      }
    },
    "/api/v1/tenants": {
      "get": {
        "operationId": "listTenants",
        "tags": ["Tenants"],
        "summary": "List tenants",
        "description": "Scoped by X-Tenant-ID header if present. Without it (the platform\nscope) one page, newest first: `total` counts every tenant the\nfilters match.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TenantScope"
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": ["pending", "active", "suspended", "terminated"]
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Part of the name or legal name (no `%`, `_` or backslash)",
            "schema": {
              "type": "string",
              "maxLength": 100
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Tenant list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "tenants": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Tenant"
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "limit": {
                      "type": "integer"
                    },
                    "offset": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createTenant",
        "tags": ["Tenants"],
        "summary": "Onboard new tenant entity",
        "description": "Creates a new tenant in `pending` state. The tenant must be activated\nvia `POST /api/v1/tenants/{tenantId}/activate` after compliance review.\nEach tenant receives isolated ledger configuration, feature flags, and\ntransfer limits. Supports four entity types: `internal` (platform\noperations), `fintech` (licensed EMI/PI), `bank` (credit institution),\nand `platform` (marketplace operator).\n\nThe regulatory profile (licence pack, home regime, further regimes,\ndata region, key mode) and the bank's cell are set here; without\nthem the defaults by jurisdiction apply. They are checked before\nanything is written: a pack of another home regime (422\n`pack_regime_mismatch`), an unknown jurisdiction or cell, a cell of\nanother jurisdiction (422 `cell_jurisdiction_mismatch`), a taken new\ncell id (409 `cell_exists`). Audited as `TENANT_CREATED` with the\nprofile.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTenantRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Tenant created"
          },
          "400": {
            "description": "`invalid_field` (with `field`)"
          },
          "409": {
            "description": "`cell_exists`"
          },
          "422": {
            "description": "`pack_regime_mismatch`, `pack_jurisdiction_mismatch`, `unknown_licence_pack`, `unknown_jurisdiction`, `unknown_cell`, `cell_jurisdiction_mismatch`, `jurisdiction_required`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Tenant"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tenants/{tenantId}": {
      "get": {
        "operationId": "getTenant",
        "tags": ["Tenants"],
        "summary": "Get tenant by ID",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TenantId"
          }
        ],
        "responses": {
          "200": {
            "description": "Tenant details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Tenant"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "patch": {
        "operationId": "updateTenant",
        "tags": ["Tenants"],
        "summary": "Update tenant",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TenantId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "legal_name": {
                    "type": "string"
                  },
                  "webhook_url": {
                    "type": "string",
                    "format": "uri"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Tenant updated"
          }
        }
      }
    },
    "/api/v1/tenants/{tenantId}/activate": {
      "post": {
        "operationId": "activateTenant",
        "tags": ["Tenants"],
        "summary": "Activate tenant (compliance-approved transition)",
        "description": "Until a bank was once live (`onboarded_at` unset; also when it went\nfrom pending to suspended) every activation needs every item of the\nonboarding checklist (`GET /api/v1/tenants/{tenantId}/onboarding`),\nchecked again under the bank's row lock; otherwise 409\n`activation_not_ready` with `missing` (the items) and `checklist`.\nResuming a bank that was live does not.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TenantId"
          }
        ],
        "responses": {
          "200": {
            "description": "Tenant activated"
          },
          "409": {
            "description": "`activation_not_ready` (`missing`, `checklist`), or the tenant is terminated"
          }
        }
      }
    },
    "/api/v1/tenants/{tenantId}/suspend": {
      "post": {
        "operationId": "suspendTenant",
        "tags": ["Tenants"],
        "summary": "Suspend tenant (blocks all financial operations)",
        "description": "A reason is required. The change and its audit rows\n(`tenant.status.changed` in the ledger audit, `TENANT_SUSPENDED` in\nthe platform audit) are one transaction; without the rows nothing\nchanges (503).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TenantId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReasonBody"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Tenant suspended"
          },
          "400": {
            "description": "`reason_required`"
          },
          "503": {
            "description": "`audit_unavailable`: nothing changed"
          }
        }
      }
    },
    "/api/v1/tenants/{tenantId}/terminate": {
      "post": {
        "operationId": "terminateTenant",
        "tags": ["Tenants"],
        "summary": "Ask to terminate a tenant (irreversible; four-eyes)",
        "description": "Never at once (Super-Admin audit 2026-10-06): a request that another\nsuper_admin approves before it expires\n(`POST /api/v1/platform/approvals/{id}/approve`). A reason is\nrequired. Open accounts, open safeguarding accounts or a non-zero\nsafeguarding balance, and open compliance cases block the request\n(409 `terminate_blocked` with the checks) unless `override_reason`\nis given; the checks run again on approval. Platform super_admin\nonly.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TenantId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["reason"],
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1000
                  },
                  "override_reason": {
                    "type": "string",
                    "maxLength": 1000,
                    "description": "Ask despite blocking checks (recorded in the request)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "`{status: pending_approval, approval, checks}`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlatformApprovalPending"
                }
              }
            }
          },
          "400": {
            "description": "`reason_required` or `invalid_field`"
          },
          "403": {
            "description": "`forbidden_role`"
          },
          "409": {
            "description": "`terminate_blocked` (with `checks`), `approval_pending` or `already_terminated`"
          }
        }
      }
    },
    "/api/v1/tenants/{tenantId}/terminate-checks": {
      "get": {
        "operationId": "getTenantTerminateChecks",
        "tags": ["Tenants"],
        "summary": "What terminating the tenant would strand (platform super_admin)",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TenantId"
          }
        ],
        "responses": {
          "200": {
            "description": "`{checks: TerminateChecks}`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "checks": {
                      "$ref": "#/components/schemas/TerminateChecks"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`forbidden_role`"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/tenants/{tenantId}/onboarding": {
      "get": {
        "operationId": "getTenantOnboarding",
        "tags": ["Tenants"],
        "summary": "The onboarding checklist of a bank",
        "description": "Every item with `done`, and the `missing` ones, in this order:\n`cell` (the bank serves from a cell), `kyc_config` (an active KYC\nconfiguration), `currencies` (enabled, the default among them),\n`products` (a payment rail switched on and in the licence pack),\n`bank_admin` (a first bank_admin in the cell), `api_key` (an active\nAPI credential), `sca_policy` (set explicitly by the platform),\n`webhook` (an outgoing notification endpoint). The first activation\nneeds all of them.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TenantId"
          }
        ],
        "responses": {
          "200": {
            "description": "Checklist",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantOnboarding"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/tenants/{tenantId}/cell": {
      "post": {
        "operationId": "assignTenantCell",
        "tags": ["Tenants"],
        "summary": "Map a bank without a cell to one (platform super_admin)",
        "description": "Once: a bank with a cell keeps it (moving it is a runbook). The cell\nserves the bank's jurisdiction; `new_cell` creates it. Audited as\n`TENANT_CELL_ASSIGNED`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TenantId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["reason"],
                "properties": {
                  "cell_id": {
                    "type": "string",
                    "example": "airis-es"
                  },
                  "new_cell": {
                    "$ref": "#/components/schemas/NewCell"
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1000,
                    "description": "Recorded with the change (finance and platform audit rows)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`{id, cell_id}`"
          },
          "400": {
            "description": "`reason_required`, `invalid_field`"
          },
          "403": {
            "description": "`forbidden_role`"
          },
          "409": {
            "description": "`cell_assigned`, `cell_exists`, `tenant_terminated`"
          },
          "422": {
            "description": "`unknown_cell`, `cell_jurisdiction_mismatch`, `jurisdiction_required`"
          }
        }
      }
    },
    "/api/v1/tenants/{tenantId}/api-key": {
      "post": {
        "operationId": "generateTenantApiKey",
        "tags": ["Tenants"],
        "summary": "Generate API key for tenant (secret shown once)",
        "description": "The legacy tenant key. A super_admin staff session in the platform\nscope, with a reason; audited as `TENANT_API_KEY_ISSUED`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TenantId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["reason"],
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1000,
                    "description": "Recorded with the change (finance and platform audit rows)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "API key generated (secret shown once)"
          },
          "400": {
            "description": "`reason_required`"
          },
          "403": {
            "description": "`forbidden_role`"
          }
        }
      },
      "delete": {
        "operationId": "revokeTenantApiKey",
        "tags": ["Tenants"],
        "summary": "Revoke tenant API key",
        "description": "A super_admin staff session in the platform scope, with a reason in\nthe body (never in the address); audited as `TENANT_API_KEY_REVOKED`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TenantId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["reason"],
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "API key revoked"
          },
          "400": {
            "description": "`reason_required`"
          },
          "403": {
            "description": "`forbidden_role`"
          }
        }
      }
    },
    "/api/v1/tenants/{tenantId}/settings": {
      "get": {
        "operationId": "getTenantSettings",
        "tags": ["Tenants"],
        "summary": "Get tenant limits and features",
        "description": "Returns the effective tenant settings: transfer limits (single,\ndaily, monthly), maximum\ncustomers, maximum accounts per customer, and feature flags\n(SEPA SCT, SEPA Instant, SEPA DD, SWIFT, Cards, FX, Webhooks).\n`sca_threshold`, `sca_threshold_tenant` and `sca_threshold_global`\nare always 0 since 0.34.0 and deprecated: they are removed in the\nnext release. There is no amount threshold; every customer payment\nneeds SCA unless exempt, under the tenant's SCA policy\n(`GET|PATCH /api/v1/tenants/{tenantId}/sca-policy`).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TenantId"
          }
        ],
        "responses": {
          "200": {
            "description": "Tenant settings"
          }
        }
      },
      "patch": {
        "operationId": "updateTenantSettings",
        "tags": ["Tenants"],
        "summary": "Update tenant limits",
        "description": "Partially updates the tenant's configurable settings. Only provided\nfields are modified; omitted fields are left unchanged. Supports\ntransfer limits and feature flags. Platform settings (DEC-0042): a\nstaff `super_admin` in the platform scope or a service writes them; a\nbank session gets 403 `forbidden_role`. `sca_threshold` is accepted and\nignored since 0.34.0 (deprecated, removed in the next release; there\nis no amount threshold).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TenantId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sca_threshold": {
                    "type": "integer",
                    "deprecated": true,
                    "description": "Ignored since 0.34.0 (no SCA amount threshold)"
                  },
                  "single_transfer_limit": {
                    "type": "integer",
                    "minimum": 0,
                    "description": "EUR minor units"
                  },
                  "daily_transfer_limit": {
                    "type": "integer",
                    "minimum": 0,
                    "description": "EUR minor units"
                  },
                  "monthly_transfer_limit": {
                    "type": "integer",
                    "minimum": 0,
                    "description": "EUR minor units"
                  },
                  "max_customers": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "max_accounts_per_customer": {
                    "type": "integer",
                    "minimum": 0
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Settings updated"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "400": {
            "description": "A negative value, or single > daily > monthly where both are set (DEC-0042)"
          }
        }
      }
    },
    "/api/v1/tenants/{tenantId}/webhook-endpoint": {
      "get": {
        "operationId": "getTenantWebhookEndpoint",
        "tags": ["Tenants"],
        "summary": "The bank's webhook endpoint (outgoing notifications)",
        "description": "The tenant's bank_admin, mlro, auditor and coo read it; a staff\n`super_admin` in the platform scope reads any tenant's; the service\nkey reads with its tenant. Another tenant: 403 `forbidden`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TenantId"
          }
        ],
        "responses": {
          "200": {
            "description": "The endpoint (null when none is set)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantWebhookEndpoint"
                }
              }
            }
          },
          "403": {
            "description": "`forbidden_role`, `forbidden`"
          },
          "404": {
            "description": "`not_found`"
          }
        }
      },
      "put": {
        "operationId": "setTenantWebhookEndpoint",
        "tags": ["Tenants"],
        "summary": "Set the bank's webhook endpoint (DEC-0042)",
        "description": "The bank's own system: its `bank_admin` only (DEC-0042; a\n`super_admin` reads it and gets 403 `forbidden_role` on a change).\nChecked before it is stored: `https://` only, at\nmost 500 characters, no user name or password, a host that is not\na private name, and every address the host resolves to is public\n(no loopback, private, link-local, carrier-grade NAT, documentation,\nmulticast or reserved range, also inside IPv4-mapped and NAT64\naddresses). Refused: 422 `invalid_webhook_url` with `note`\n(`invalid_url`, `blocked_host`, `unresolvable`,\n`private_address`). `null` clears it. A change writes one audit row\n(`webhook_configured`) with the address before and after.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TenantId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["webhook_url"],
                "properties": {
                  "webhook_url": {
                    "type": ["string", "null"],
                    "format": "uri",
                    "maxLength": 500
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantWebhookEndpoint"
                }
              }
            }
          },
          "403": {
            "description": "`forbidden_role` (not bank_admin or a platform super_admin), `forbidden`"
          },
          "404": {
            "description": "`not_found`"
          },
          "422": {
            "description": "`invalid_webhook_url` with `note`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tenants/{tenantId}/currencies/{currencyCode}": {
      "delete": {
        "operationId": "disableTenantCurrency",
        "tags": ["Tenants"],
        "summary": "Remove a currency of a bank (platform, with a reason)",
        "description": "Refused for the default or the last enabled currency (400) and while accounts of the bank still hold it (409 currency_in_use, DEC-0042). A reason is required and recorded with the change; finance-api reads no DELETE body, so it is a query parameter.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tenantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "currencyCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Z]{3}$"
            }
          },
          {
            "name": "reason",
            "in": "query",
            "required": true,
            "description": "Why (10 to 1000 characters, percent-encoded); written into the audit row of the change.",
            "schema": {
              "type": "string",
              "minLength": 10,
              "maxLength": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The bank's currencies after the change"
          },
          "400": {
            "description": "reason_required, or the default or last enabled currency"
          },
          "409": {
            "description": "currency_in_use: accounts of the bank still hold this currency"
          }
        }
      }
    },
    "/api/v1/tenants/{tenantId}/features": {
      "patch": {
        "operationId": "updateTenantFeatures",
        "tags": ["Tenants"],
        "summary": "Switch tenant features (the bank decides, DEC-0031)",
        "description": "Partially updates the tenant's feature flags. Only provided fields are\nmodified; omitted fields are left unchanged.\n\n**The licence pack advises, the bank decides (DEC-0031).** The\nlicence pack's `enabled_rails` is the typical scope of the licence\ntype, not a ceiling: a feature outside it may be switched on with a\n`reason` (1 to 500 characters after trimming Unicode whitespace; no\nraw or escaped control characters other than escaped tab and line\nbreaks, no bidi controls, soft hyphen, zero-width space, word joiner,\ninvisible operators, BOM or tag characters; ZWNJ and ZWJ are\nallowed), and the answer lists it under `advisories`. Switching on a feature the platform cannot run is\nrefused for every tenant (`feature_unavailable`: `sepa_dd`, note\n`no_mandate_flow`; `fps`, note `no_provider`); repeating a stored\nvalue is not a switch.\n\nOnly the keys that change are written. A rail flag that was never\nstored follows the pack and never opens more than the old ceiling\ndid: `sepa_sct` is on only when the pack lists it, `sic_ip` follows\n`sic` only when the pack lists it, every other rail is off. SIC and\nSIC IP have separate switches.\n\nEvery changed feature (on or off, inside or outside the pack) writes\none `tenant_feature_changed` row (event code 704) to the hash-chained\naudit log in the same transaction as the update, with actor id, type\nand role, tenant, feature, from, to, `outside_pack`, licence pack and\nreason. When the audit row cannot be written, nothing changes.\n\nWho may call: the bank's own admin (`bank_admin`) for its own tenant,\nthe platform `super_admin`, and services. Other roles get 403; staff\nof another tenant get 403. Payments follow the switch: a transfer\nneeds the platform capability and the tenant feature, not the pack.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TenantId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sepa_sct": {
                    "type": "boolean",
                    "description": "SEPA Credit Transfer"
                  },
                  "sepa_instant": {
                    "type": "boolean",
                    "description": "SEPA Instant Payment"
                  },
                  "sepa_dd": {
                    "type": "boolean",
                    "description": "SEPA Direct Debit. Switching it on is refused (feature_unavailable)."
                  },
                  "swift": {
                    "type": "boolean",
                    "description": "SWIFT transfers"
                  },
                  "sic": {
                    "type": "boolean",
                    "description": "SIC (Swiss CHF)"
                  },
                  "sic_ip": {
                    "type": "boolean",
                    "description": "SIC instant payments"
                  },
                  "cards": {
                    "type": "boolean",
                    "description": "Card issuing"
                  },
                  "fx": {
                    "type": "boolean",
                    "description": "FX exchange"
                  },
                  "webhooks": {
                    "type": "boolean",
                    "description": "Webhook delivery"
                  },
                  "assistant": {
                    "type": "boolean",
                    "description": "Money assistant. On needs a person route: support_chat on or a branding support_email (422 human_route_required)."
                  },
                  "support_chat": {
                    "type": "boolean",
                    "description": "Support thread for customers (DEC-0032, ARCH-029a). Off needs support_ai off."
                  },
                  "support_ai": {
                    "type": "boolean",
                    "description": "AI first line in the support thread. Needs support_chat on (human_route_required); refused for the Art. 1b licence pack until counsel's opinion (feature_unavailable, note counsel_pending, DEC-0032). In production without a ZDR model endpoint, and for a language not evaluated, it runs templates only (advice notes templates_only, templates_unevaluated_locales)."
                  },
                  "support_tickets": {
                    "type": "boolean",
                    "description": "Customer tickets (ARCH-030 \u00a73.1, DEC-0033), independent of support_chat. Needs the support bucket (S3_BUCKET_SUPPORT answered a HEAD at boot), never a scanner: without it switching on is 422 feature_unavailable with note no_file_store."
                  },
                  "reason": {
                    "type": "string",
                    "maxLength": 500,
                    "description": "Why the bank switches on a feature outside its licence\npack. Required (1 to 500 characters after trimming) only\nthen; otherwise optional and recorded with the change.\n"
                  }
                }
              },
              "example": {
                "sic": true,
                "reason": "SIC access through our partner bank"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Features updated; the tenant settings as GET /settings plus `advisories`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantFeaturesUpdated"
                }
              }
            }
          },
          "403": {
            "description": "`{\"error\":\"forbidden\"}`: a role without the right, or another tenant"
          },
          "404": {
            "description": "Tenant not found"
          },
          "422": {
            "description": "`feature_unavailable` (the platform cannot run the feature),\n`reason_required` (switching on a feature outside the licence pack\nwithout a reason of 1 to 500 characters) or\n`human_route_required` (ARCH-029a \u00a72.1: `support_ai` on with\n`support_chat` off, or the money assistant on with neither\n`support_chat` nor a branding `support_email`).\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantFeatureError"
                },
                "examples": {
                  "feature_unavailable": {
                    "value": {
                      "error": {
                        "code": "feature_unavailable",
                        "message": "SEPA Direct Debit is not available on this platform yet",
                        "feature": "sepa_dd",
                        "note": "no_mandate_flow"
                      }
                    }
                  },
                  "reason_required": {
                    "value": {
                      "error": {
                        "code": "reason_required",
                        "message": "Enabling SIC is outside the EMI licence pack: give a reason",
                        "feature": "sic",
                        "licence_pack": "emi"
                      }
                    }
                  },
                  "human_route_required": {
                    "value": {
                      "error": {
                        "code": "human_route_required",
                        "message": "The AI first line needs the support thread with a person",
                        "feature": "support_ai"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tenants/{tenantId}/features/advice": {
      "get": {
        "operationId": "getTenantFeatureAdvice",
        "tags": ["Tenants"],
        "summary": "Licence pack advice per feature (DEC-0031)",
        "description": "Per feature, in a fixed order (sepa_sct, sepa_instant, sepa_dd,\nswift, sic, sic_ip, cards, fx, webhooks, assistant, support_chat,\nsupport_ai, support_tickets): whether it is on,\ninside the tenant's licence pack (advice only), and available on the\nplatform (`note` says why not). `enabled` is what the payment gate\nreads: a flag never stored follows the pack (see PATCH). Non-rail\nfeatures (cards, fx, webhooks, assistant, support_chat, support_ai,\nsupport_tickets) are always `in_pack: true`. `support_tickets` is\n`available: false` with note `no_file_store` while the support\nbucket did not answer at boot (ARCH-030 \u00a73.1; no scanner needed). `support_ai` runs in one of two modes\n(ARCH-029a \u00a72.1, amendment 2026-10-02): with an allowed ZDR model\nendpoint the model answers, in production only in the languages\nlisted in SUPPORT_AI_EVALUATED_LOCALES (`model_locales`, note\n`templates_unevaluated_locales`: every other language runs\ntemplates; with none listed, note `templates_only`); in production\nwithout such an endpoint it is `available: true` with note\n`templates_only` (rules, local moderation and help-article answers;\nno model is called, no evaluation needed). Staff of that\ntenant, platform staff and services; another tenant's staff get 403.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TenantId"
          }
        ],
        "responses": {
          "200": {
            "description": "Advice per feature",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantFeatureAdvice"
                }
              }
            }
          },
          "403": {
            "description": "`{\"error\":\"forbidden\"}`: another tenant, or a caller without staff rights"
          },
          "404": {
            "description": "Tenant not found"
          }
        }
      }
    },
    "/api/v1/tenants/{tenantId}/deposit-cap": {
      "get": {
        "operationId": "getTenantDepositCap",
        "tags": ["Tenants"],
        "summary": "Deposit cap and safeguarding figures of a bank",
        "description": "The Art. 1b deposit cap (FinTech licence and Swiss sandbox) and the\nsafeguarding of customer funds (e-money and payment institutions),\nread live from the ledger. Every staff role of that bank and the\nplatform read it; another bank's staff get 403.\n\n`reporting_currency` is the currency the bank reports safeguarding\nin: CHF for a Swiss FinTech or sandbox bank (the cap's unit), else\nthe currency of the bank's jurisdiction (EUR for an e-money or\npayment institution in the euro area), EUR without one.\n`safeguarding_emoney_minor`, `safeguarding_accounts_minor` and\n`safeguarding_shortfall_minor` are in that currency. The `*_chf_minor`\nfields are the cap's CHF figures; for a bank reporting in another\ncurrency they are CHF equivalents, null when no CHF rate is\navailable. `safeguarding_match` and the statuses come from the\nreporting currency; the verdict is per currency\n(`safeguarding_by_currency`): a surplus in one currency does not\ncover a shortfall in another. A ledger that cannot be read is\n`unknown` and null, never zero. `chf_rate_live` and `chf_rate_from`\nsay where the report's CHF rate came from: the report takes a valid\nstatic CHF rate too (`static_row`), or for a report in another\ncurrency the static reference table (`static_table`), while the\ncap's own decisions take a live rate only (`live_row`: a provider\nfeed or an override).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TenantId"
          }
        ],
        "responses": {
          "200": {
            "description": "Cap and safeguarding figures",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DepositCapStatus"
                }
              }
            }
          },
          "400": {
            "description": "Invalid tenant ID"
          },
          "403": {
            "description": "`{\"error\":\"forbidden\"}`: another tenant, or a caller without staff rights"
          },
          "404": {
            "description": "Tenant not found"
          },
          "503": {
            "description": "`{\"error\":\"fx_rate_unavailable\"}`: no exchange rate for the reporting currency"
          }
        }
      }
    },
    "/api/v1/tenants/{tenantId}/document-retention": {
      "get": {
        "operationId": "getTenantDocumentRetention",
        "tags": ["Tenants"],
        "summary": "Document retention of a tenant (ARCH-030 \u00a73.3)",
        "description": "Per setting: the tenant's override (null: the platform default), the\nplatform default, the effective value, the legal minimum and its\nbasis. `cdd_documents_years` (KYC media copies of accepted CDD\ndocuments, text of cdd tickets): at least the jurisdiction's\n`aml_retention_years` (not set: 5, the platform minimum), at most 30.\n`customer_letters_years` (letters): 6 (the platform minimum) to 30.\n`basis` names the legal source of each minimum. Counted from the end\nof the business relationship.\n`super_admin` (platform scope, any tenant), `bank_admin`, `mlro`\nand `auditor` of the tenant, and the service key; other roles 403\n`forbidden_role`. Reads are unchanged by DEC-0036: finance-api and\nthe bank read the effective value.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TenantId"
          }
        ],
        "responses": {
          "200": {
            "description": "The settings",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantDocumentRetention"
                }
              }
            }
          },
          "403": {
            "description": "`forbidden_role` (role), `forbidden` (another tenant)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          },
          "404": {
            "description": "Tenant not found"
          },
          "503": {
            "description": "`retention_unavailable`, `Retry-After: 5`"
          }
        }
      },
      "patch": {
        "operationId": "updateTenantDocumentRetention",
        "tags": ["Tenants"],
        "summary": "Override the document retention of a tenant (ARCH-030 \u00a73.3)",
        "description": "A member left out stays as it is; null goes back to the platform\ndefault. Below the minimum or above 30: 422 `invalid_field` with\n`field` and `limit` (the bound crossed). Records already fixed at a\nclosure are extended by a higher value at the next retention run and\nnever shortened by a lower one. Audit `tenant.retention.changed`\nwith the old and new values.\n\nA platform setting (DEC-0036, 0.30.0): only a staff `super_admin` in\nthe platform scope writes it, for any tenant (Super-Admin, tenant\npage). `bank_admin`, `mlro` and `auditor` of the tenant, and the\nservice key, are 403 `platform_only` (checked before the body);\nother roles 403 `forbidden_role`.\nA staff PATCH names a `reason` (1 to 1000 characters; 400\n`reason_required`); it goes into the audit rows, written on the\nrequest transaction.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TenantId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TenantDocumentRetentionPatch"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The settings after the change",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantDocumentRetention"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_json`"
          },
          "403": {
            "description": "`platform_only` (the bank's readers and the service key; 0.30.0), `forbidden_role` (role), `forbidden` (another tenant)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          },
          "404": {
            "description": "Tenant not found"
          },
          "422": {
            "description": "`invalid_field` with `field`, `limit`, `minimum`, `maximum`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          },
          "503": {
            "description": "`retention_unavailable`, `Retry-After: 5`"
          }
        }
      }
    },
    "/api/v1/tenants/{tenantId}/sca-policy": {
      "get": {
        "operationId": "getTenantScaPolicy",
        "tags": ["Tenants"],
        "summary": "Strong customer authentication policy of a tenant (DEC-0039)",
        "description": "The tenant's SCA mode and settings with every default filled in, and\n`effective_mode`, the mode the gate applies now (`optional` is\n`required` from `grace_until`). Read by the finance-api SCA gate on\nevery customer transfer and card write, and by identity-api for its\ndevice settings.\n\nA platform setting (0.34.0): only a staff `super_admin` in the\nplatform scope writes it, for any tenant (an `X-Tenant-ID` for\nanother tenant is 403 `forbidden`). The tenant's own staff read it\n(DEC-0043: every role of the bank's cell except the support roles,\nwhich get 403 `forbidden_role`); another tenant's staff are 403\n`forbidden`, the service key 403 `forbidden_role`; customers never\nreach `/tenants` routes.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TenantId"
          }
        ],
        "responses": {
          "200": {
            "description": "The policy",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantScaPolicy"
                }
              }
            }
          },
          "403": {
            "description": "`forbidden_role` (a support role or the service key), `forbidden` (another tenant)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`: no such tenant"
          },
          "503": {
            "description": "`sca_policy_unavailable`, `Retry-After: 5`"
          }
        }
      },
      "patch": {
        "operationId": "updateTenantScaPolicy",
        "tags": ["Tenants"],
        "summary": "Change the SCA policy of a tenant (DEC-0039)",
        "description": "Names the members to change; the others keep their value. The\npolicy is then stored complete. The same values again change\nnothing and write no audit row (idempotent). A change writes one\naudit row (`config_updated`, action `tenant.sca_policy.changed`)\nwith the policy before and after and the actor, in the same\ntransaction: when it cannot be written nothing changes. No\n`If-Match`: the tenant routes carry no ETag.\n\nThe rollout: `off` (every tenant at first: the caller's own access\ntoken is still accepted as `X-SCA-Token` for what is not exempt),\nthen `optional` with `grace_until` (approval on the bound phone;\ncustomers without one keep the access token), then `required` (at\n`grace_until`, or set directly). `off` again is the rollback.\n\nEach member is checked as the database checks it; a refused member\nis 400 with its `field`: `invalid_json` (`body`), `unknown_field`\n(also inside `low_value`, as `low_value.<name>`), `invalid_field`\n(an empty object names `body`).\n\n`app_build_too_low` (field `min_app_build`): a change that names\n`sca_device_approval` or `min_app_build` may not leave the setting\n`optional` or `required` with `min_app_build` below 15. App build 14\nand older cannot show a phone approval, `setup_required` or the 403\nSCA challenge; set the minimum first (or in the same change). `off`\nis always accepted.\nWho may call it: as GET.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TenantId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TenantScaPolicyPatch"
              },
              "example": {
                "sca_device_approval": "optional",
                "grace_until": "2026-11-05T00:00:00Z"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The policy after the change (or unchanged)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantScaPolicy"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_json`, `unknown_field`, `invalid_field` or `app_build_too_low` with `field`, e.g. `{\"error\":{\"code\":\"invalid_field\",\"message\":\"Must be an integer from 0 to 3000 (EUR 30, RTS Art. 16)\",\"field\":\"low_value.max_eur_minor\"}}`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          },
          "403": {
            "description": "`forbidden_role` (not a platform super_admin), `forbidden` (another tenant)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`: no such tenant"
          },
          "503": {
            "description": "`sca_policy_unavailable`, `Retry-After: 5`"
          }
        }
      }
    },
    "/api/v1/platform/settings/document-retention": {
      "get": {
        "operationId": "getPlatformDocumentRetention",
        "tags": ["Tenants"],
        "summary": "Platform defaults of document retention (ARCH-030 \u00a73.3)",
        "description": "The defaults every tenant without an override follows (10 years\neach), with their bounds. `super_admin` in the platform scope.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The defaults",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlatformDocumentRetention"
                }
              }
            }
          },
          "403": {
            "description": "`forbidden_role`"
          }
        }
      },
      "patch": {
        "operationId": "updatePlatformDocumentRetention",
        "tags": ["Tenants"],
        "summary": "Change the platform defaults of document retention",
        "description": "`cdd_documents_years` 5 to 30 (a tenant never gets less than its\njurisdiction's minimum), `customer_letters_years` 6 to 30; integers,\nnever null. Only a staff `super_admin` in the platform scope (no\nX-Tenant-ID): else 403 `platform_scope_required`; the service key\nreads only (403 `forbidden_role`). Audit `platform.setting.changed` per\nchanged setting with the old and new value.\nA staff PATCH names a `reason` (1 to 1000 characters; 400\n`reason_required`); it goes into the audit rows, written on the\nrequest transaction.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PlatformDocumentRetentionPatch"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The defaults after the change",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlatformDocumentRetention"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_json`"
          },
          "403": {
            "description": "`forbidden_role`, `platform_scope_required`"
          },
          "422": {
            "description": "`invalid_field` with `field`, `limit`, `minimum`, `maximum`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          },
          "503": {
            "description": "`retention_unavailable`, `Retry-After: 5`"
          }
        }
      }
    },
    "/api/v1/platform/ai-policy": {
      "get": {
        "operationId": "getPlatformAiPolicy",
        "tags": ["Tenants"],
        "summary": "The platform AI policy of the support AI (DEC-0034)",
        "description": "The active version, the drafts (each with `diff` against the active\nversion and `stale` when the active version changed since), the\nhistory, the platform kill switch, the vocabularies and the\ncaller's id (`viewer_id`, to tell own drafts). `super_admin` in the\nplatform scope; the service key reads. ARCH-029a \u00a711.5.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The platform policy",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AiPolicyOverview"
                }
              }
            }
          },
          "403": {
            "description": "`forbidden_role`"
          },
          "503": {
            "description": "`ai_policy_unavailable`, `Retry-After: 5`"
          }
        }
      }
    },
    "/api/v1/platform/ai-policy/drafts": {
      "post": {
        "operationId": "createAiPolicyDraft",
        "tags": ["Tenants"],
        "summary": "Draft a new platform AI policy version",
        "description": "The whole policy and a `reason` (1 to 500 characters). Stored as a\ndraft based on the active version; a different super_admin\napproves it (four-eyes). Platform scope only (403\n`platform_scope_required`), a staff session naming a person (403\n`forbidden_role`). Change log `draft`, audit `ai_policy.drafted`\nwith the diff.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AiPolicyDraftInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The draft",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AiPolicyVersion"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_json`"
          },
          "403": {
            "description": "`forbidden_role`, `platform_scope_required`"
          },
          "422": {
            "description": "`invalid_field` with `field`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/platform/ai-policy/drafts/{draftId}/approve": {
      "post": {
        "operationId": "approveAiPolicyDraft",
        "tags": ["Tenants"],
        "summary": "Approve a draft (four-eyes)",
        "description": "Only a super_admin other than the draft's author (403\n`four_eyes_required`). The draft becomes the active version and the\none before it is superseded, in one transaction. 409 `not_draft`\n(decided already), 409 `draft_stale` (the active version changed\nsince the draft was written: write a new one). Optional `reason`.\nChange log `approved` (author and approver) and `active`, audit\n`ai_policy.approved`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "draftId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AiPolicyDecisionInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The active version",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AiPolicyVersion"
                }
              }
            }
          },
          "403": {
            "description": "`forbidden_role`, `platform_scope_required`, `four_eyes_required`"
          },
          "404": {
            "description": "`not_found`"
          },
          "409": {
            "description": "`not_draft`, `draft_stale`"
          }
        }
      }
    },
    "/api/v1/platform/ai-policy/drafts/{draftId}/reject": {
      "post": {
        "operationId": "rejectAiPolicyDraft",
        "tags": ["Tenants"],
        "summary": "Reject a draft",
        "description": "Any super_admin, the author too (a withdrawal), with a `reason`.\nChange log `rejected`, audit `ai_policy.rejected`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "draftId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AiPolicyDecisionInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The rejected version",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AiPolicyVersion"
                }
              }
            }
          },
          "403": {
            "description": "`forbidden_role`, `platform_scope_required`"
          },
          "404": {
            "description": "`not_found`"
          },
          "409": {
            "description": "`not_draft`"
          },
          "422": {
            "description": "`invalid_field` (`reason`)"
          }
        }
      }
    },
    "/api/v1/platform/ai-policy/kill": {
      "put": {
        "operationId": "setAiPolicyKill",
        "tags": ["Tenants"],
        "summary": "The platform kill switch of the support AI",
        "description": "`{kill, reason}`. Setting it (`kill: true`) is immediate and one\nsuper_admin's (safety). Clearing it needs a second person: the first\n`kill: false` records a clear request (202, `step: clear_requested`,\nthe AI stays stopped); the same super_admin again is 403\n`four_eyes_required`; a different super_admin's `kill: false` clears it\n(200, `step: cleared`). `kill: true` while a request is pending\nwithdraws it. While set no AI turn is dispatched (`policy_kill`), no\ntool runs and no AI message is stored. Change log `platform_kill`\n(`active` set, `draft` request, `approved` clear with requester and\napprover), audit `ai_policy.kill_changed`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["kill", "reason"],
                "properties": {
                  "kill": {
                    "type": "boolean"
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The kill switch (set, cleared or unchanged)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AiPolicyKill"
                }
              }
            }
          },
          "202": {
            "description": "Clear requested; a different super_admin confirms it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AiPolicyKill"
                }
              }
            }
          },
          "403": {
            "description": "`forbidden_role`, `platform_scope_required`, `four_eyes_required`"
          },
          "422": {
            "description": "`invalid_field`"
          }
        }
      }
    },
    "/api/v1/platform/ai-policy/changes": {
      "get": {
        "operationId": "listAiPolicyChanges",
        "tags": ["Tenants"],
        "summary": "The AI policy change log",
        "description": "Newest first; `tenant_id` filters one tenant, `limit` 1 to 500 (default 100). Append-only.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Changes",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AiPolicyChanges"
                }
              }
            }
          },
          "403": {
            "description": "`forbidden_role`"
          }
        }
      }
    },
    "/api/v1/platform/approvals": {
      "get": {
        "operationId": "listPlatformApprovals",
        "tags": ["Tenants"],
        "summary": "Four-eyes requests of the platform (super_admin, platform scope)",
        "description": "Terminate a bank, create a super_admin account, make an operator\nsuper_admin (Super-Admin audit 2026-10-06, migration 272), give an\noperator bank_admin in a bank's cell (migration 282), change a\nlicence pack's ceilings (migration 284). Newest\nfirst, one page with the total of all pages; pending requests past\ntheir expiry (72 hours) turn `expired` first, each with a\n`PLATFORM_APPROVAL_EXPIRED` audit row. `status` is one status, or\n`decided` (every status but `pending`) or `all`. `target` matches\nwhat a request is about: an operator's id (also the operator of a\nbank access grant), a licence pack code, a bank id, an e-mail. A\npending termination carries `live_checks`, run at the time of the\nlist, next to the snapshot in `payload.checks` (UX review 2026-10-07\nWP9).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "pending",
                "approved",
                "rejected",
                "withdrawn",
                "expired",
                "decided",
                "all"
              ],
              "default": "pending"
            }
          },
          {
            "name": "action",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "tenant_terminate",
                "staff_create_super_admin",
                "staff_promote_super_admin",
                "staff_reset_password",
                "staff_reset_mfa",
                "staff_grant_bank_admin",
                "staff_grant_mlro",
                "licence_pack_change"
              ]
            }
          },
          {
            "name": "tenant_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "target",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{approvals: [...], viewer_id, total, limit, offset, ttl_hours}`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "approvals": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PlatformApproval"
                      }
                    },
                    "viewer_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "limit": {
                      "type": "integer"
                    },
                    "offset": {
                      "type": "integer"
                    },
                    "ttl_hours": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`invalid_field`: an unknown status or action, a bank id that is not a UUID"
          },
          "403": {
            "description": "`forbidden_role`"
          }
        }
      }
    },
    "/api/v1/platform/approvals/{approvalId}/approve": {
      "post": {
        "operationId": "approvePlatformApproval",
        "tags": ["Tenants"],
        "summary": "Approve a request (a super_admin other than the requester)",
        "description": "Runs the change in the same transaction as the decision, with its\naudit rows. A new credential (a created super_admin's temporary\npassword, a promoted operator's or a reset's enrolment token or\npassword) goes to the account's own e-mail, never into the answer\n(review H1). Refused when someone else set the approver's credentials\nin the last 72 hours (403 `approver_cooling_off`) or the requester\never did (403 `reset_by_requester`), and when the requester is no\nlonger an active super_admin (409 `requester_ineligible`). A real\nstaff session only: a service key acting for an operator is 403\n(review H2).\n\nThe approver gives a reason of 10 to 1000 characters (422\n`reason_required`, checked after who may approve). A termination\nnames the checks the approver saw (`expected_checks`, from\n`GET /api/v1/tenants/{id}/terminate-checks`; 422 `checks_required`\nwithout them): they run again in the approval's transaction, and a\ndifferent count is 409 `checks_changed` with the checks now, nothing\nterminated, the request still pending. The result keeps the checks\nat approval.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "approvalId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["reason"],
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 10,
                    "maxLength": 1000
                  },
                  "expected_checks": {
                    "type": "object",
                    "description": "`tenant_terminate` only: the counts the approver saw",
                    "properties": {
                      "open_accounts": {
                        "type": "integer"
                      },
                      "open_safeguarding_accounts": {
                        "type": "integer"
                      },
                      "safeguarding_balance_accounts": {
                        "type": "integer"
                      },
                      "open_cases": {
                        "type": "integer"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`{status: approved, approval, result}` (`result.credential_delivery: email` when a credential was mailed)"
          },
          "403": {
            "description": "`four_eyes_required`, `approver_cooling_off`, `reset_by_requester` or `forbidden_role`"
          },
          "404": {
            "description": "`not_found`"
          },
          "409": {
            "description": "`not_pending`, `approval_expired`, `terminate_blocked`, `checks_changed` (with `checks`), `already_terminated` or `already_done`"
          },
          "422": {
            "description": "`reason_required`, `checks_required` or `invalid_field`"
          }
        }
      }
    },
    "/api/v1/platform/approvals/{approvalId}/reject": {
      "post": {
        "operationId": "rejectPlatformApproval",
        "tags": ["Tenants"],
        "summary": "Reject a request (any super_admin; the requester's own is a withdrawal)",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "approvalId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["reason"],
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 10,
                    "maxLength": 1000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`{status: rejected | withdrawn, approval}`"
          },
          "409": {
            "description": "`not_pending` or `approval_expired`"
          },
          "422": {
            "description": "`reason_required` (10 to 1000 characters)"
          }
        }
      }
    },
    "/api/v1/platform/licence-packs": {
      "get": {
        "operationId": "listLicencePacks",
        "tags": ["Tenants"],
        "summary": "Licence packs and their ceilings (platform super_admin)",
        "description": "Every pack: deposit cap (minor units, null: none), payment rails,\nfiling channels, prudential flag, banks on it, last change; and the\nrails and filing channels a pack may list.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "`{packs: [...], known_rails: [...], known_filings: [...]}`"
          },
          "403": {
            "description": "`forbidden_role`"
          }
        }
      }
    },
    "/api/v1/platform/licence-packs/{code}/changes": {
      "post": {
        "operationId": "requestLicencePackChange",
        "tags": ["Tenants"],
        "summary": "Ask to change a pack's ceilings (four-eyes)",
        "description": "A request (202 `pending_approval`, action `licence_pack_change`)\nwith the pack as it is (`from`), as asked (`to`) and every changed\nmember with `loosens`. A higher or no deposit cap, a rail added or a\nfiling channel removed loosens a ceiling and needs\n`loosening_reason`. Another super_admin approves it\n(`POST /api/v1/platform/approvals/{approvalId}/approve`), which\nwrites the pack with a `LICENCE_PACK_CHANGED` audit row; refused\n(409 `pack_changed`) when the pack changed since the request\n(migration 284).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "art_1b"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["reason"],
                "properties": {
                  "deposit_cap_minor": {
                    "type": ["integer", "null"],
                    "minimum": 0
                  },
                  "enabled_rails": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "internal",
                        "sepa_sct",
                        "sepa_inst",
                        "sepa_dd",
                        "sic",
                        "sic_ip",
                        "swift"
                      ]
                    }
                  },
                  "enabled_filings": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "fiu_national",
                        "amla_common",
                        "goaml_v5",
                        "seco",
                        "snb_emi",
                        "crs"
                      ]
                    }
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1000
                  },
                  "loosening_reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "`{status: pending_approval, approval: PlatformApproval}`"
          },
          "400": {
            "description": "`reason_required`, `loosening_reason_required`, `invalid_field`"
          },
          "404": {
            "description": "No such pack"
          },
          "409": {
            "description": "`approval_pending`"
          },
          "422": {
            "description": "`no_change`"
          }
        }
      }
    },
    "/api/v1/tenants/{tenantId}/ai-policy": {
      "get": {
        "operationId": "getTenantAiPolicy",
        "tags": ["Tenants"],
        "summary": "A tenant's effective AI policy and overrides (DEC-0034)",
        "description": "The effective policy (platform \u2229 platform layer \u2229 bank layer), the\nplatform policy, both layers, the kill switches and what the caller\nmay edit (`can`). `super_admin` (platform scope, any tenant),\n`bank_admin` and `auditor` of the tenant; other roles 403\n`forbidden_role`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TenantId"
          }
        ],
        "responses": {
          "200": {
            "description": "The tenant's policy",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantAiPolicy"
                }
              }
            }
          },
          "403": {
            "description": "`forbidden_role`, `forbidden` (another tenant)"
          },
          "404": {
            "description": "Tenant not found"
          }
        }
      },
      "patch": {
        "operationId": "updateTenantAiPolicy",
        "tags": ["Tenants"],
        "summary": "Narrow a tenant's AI policy",
        "description": "A `super_admin` writes the `platform` layer (with `kill`; setting it\nneeds a `reason` and is immediate; clearing it is requested by one\nsuper_admin, `layers.platform.kill_clear_requested_by`, and confirmed\nby a different one, else 403 `four_eyes_required`), the tenant's\n`bank_admin` the `bank` layer (no `kill`: 403\n`kill_switch_platform_only`). A member left out stays,\nnull follows the platform. A member that widens the platform policy\nis 422 `policy_widens` with `field` (subsets of tools, actions,\nscope and locales; blocked topics and always-handoff categories are\nadded; caps lower; review sampling higher; `self_hosted_prod` and\n`zdr_required: true` stricter). Change log `tenant_override` or\n`tenant_kill`, audit `ai_policy.override_changed` or\n`ai_policy.kill_changed`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TenantId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AiPolicyOverridePatch"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The tenant's policy after the change",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantAiPolicy"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_json`"
          },
          "403": {
            "description": "`forbidden_role`, `forbidden`, `kill_switch_platform_only`"
          },
          "404": {
            "description": "Tenant not found"
          },
          "422": {
            "description": "`policy_widens` or `invalid_field` with `field`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tenants/{tenantId}/ai-policy/changes": {
      "get": {
        "operationId": "listTenantAiPolicyChanges",
        "tags": ["Tenants"],
        "summary": "A tenant's AI policy change log",
        "description": "The tenant's rows, newest first; `limit` 1 to 500. Roles as GET /tenants/{id}/ai-policy.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TenantId"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Changes",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AiPolicyChanges"
                }
              }
            }
          },
          "403": {
            "description": "`forbidden_role`, `forbidden`"
          }
        }
      }
    },
    "/api/v1/tenants/{tenantId}/branding": {
      "get": {
        "operationId": "getTenantBranding",
        "tags": ["Tenants"],
        "summary": "Get tenant branding configuration",
        "description": "Returns the tenant's white-label branding JSONB: logo URLs, color\ntheme preset, primary/accent HSL colors, and support email. Used\nby the admin branding editor.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TenantId"
          }
        ],
        "responses": {
          "200": {
            "description": "Tenant branding",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantBranding"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "patch": {
        "operationId": "updateTenantBranding",
        "tags": ["Tenants"],
        "summary": "Update tenant branding configuration",
        "description": "Partially updates the tenant branding JSONB. A member left out is\npreserved; a member sent as `null` or `\"\"` is cleared (`theme_preset`\ncannot be cleared). Color values must use HSL format (`H S% L%`, e.g.\n`220 70% 50%`). Logo/favicon URLs must use HTTPS and be at most 500\ncharacters. The change and its audit rows are written in one\ntransaction: `finance_audit_log` action `tenant.branding.update` and,\nfor a platform operator, `platform_audit_log` action\n`TENANT_BRANDING_UPDATED`, each with the branding before and after\n(`changes.branding`), the person and the optional `reason`.\n\nValidation errors (400):\n- `invalid_color_format` \u2014 color not in `H S% L%` format or out of range\n- `invalid_url` \u2014 URL is not HTTPS or exceeds 500 characters\n- `invalid_theme_preset` \u2014 preset not in allowed enum\n\n422 `human_route_required` (nested error body): clearing\n`support_email` while the money assistant is on and the tenant\nfeature `support_chat` is off (ARCH-029a \u00a72.1). Nothing changes.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TenantId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateBrandingRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Branding updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantBranding"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "description": "`human_route_required`: the money assistant would have no person route.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantFeatureError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tenants/{tenantId}/theme": {
      "get": {
        "operationId": "getTenantTheme",
        "tags": ["Tenants"],
        "summary": "Get merged tenant theme for the customer portal",
        "description": "Returns the merged theme consumed by the customer portal on server-side\nrender and by the mobile client on splash/login. Combines branding\nfields with feature flags.\n\n**Public endpoint \u2014 no authentication required.** Branding must be\navailable before a user signs in (login/splash screens). Both the Zig\nrouter (`main.zig`) and the Traefik gateway (`finance-tenant-theme`\nrouter) bypass Bearer auth for this path.\n\nFallback rules applied server-side:\n- Empty branding \u2192 `theme_preset: \"default\"`, all other branding fields `null`.\n- `app_name` = `branding.name ?? tenant.name`.\n- `theme_preset = \"custom\"` with `primary_color: null` \u2192 indigo fallback `\"220 70% 50%\"`.\n\nThe customer portal caches this response for 5 minutes via `unstable_cache`.\n",
        "security": [],
        "parameters": [
          {
            "$ref": "#/components/parameters/TenantId"
          }
        ],
        "responses": {
          "200": {
            "description": "Tenant theme configuration",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantTheme"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/tenants/{tenantId}/credentials": {
      "get": {
        "operationId": "listTenantCredentials",
        "tags": ["Credentials"],
        "summary": "List OAuth2 credentials for tenant",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TenantId"
          }
        ],
        "responses": {
          "200": {
            "description": "Credentials list"
          }
        }
      },
      "post": {
        "operationId": "createTenantCredential",
        "tags": ["Credentials"],
        "summary": "Issue OAuth2 credential pair for tenant API access",
        "description": "Creates a new `client_id` / `client_secret` pair for the tenant.\nThe `client_secret` is returned exactly once in the response and\nstored as an irreversible hash. Credentials are scoped to a specific\nenvironment (sandbox/production) and permission set. Lost secrets\nrequire credential rotation via the rotate endpoint.\nA super_admin staff session in the platform scope (not a service key\nacting for an operator), with a reason; audited in the same\ntransaction (`TENANT_API_CREDENTIAL_*`), never with the secret.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TenantId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["reason"],
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1000,
                    "description": "Recorded with the change (finance and platform audit rows)."
                  },
                  "environment": {
                    "type": "string",
                    "enum": ["sandbox", "production"],
                    "default": "sandbox"
                  },
                  "scopes": {
                    "type": "string",
                    "example": "{accounts:read,accounts:write}"
                  },
                  "confirm_production": {
                    "type": "boolean",
                    "description": "Required (true) for environment production."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Credential created (client_secret shown once)"
          },
          "400": {
            "description": "`reason_required`, `invalid_field`, `invalid_scope`, `confirmation_required` (production without confirm_production)"
          },
          "403": {
            "description": "`forbidden_role`"
          },
          "409": {
            "description": "`tenant_terminated`"
          }
        }
      }
    },
    "/api/v1/customers": {
      "get": {
        "operationId": "listCustomers",
        "tags": ["Customers"],
        "summary": "List customers",
        "description": "Filters run in the database, so `total` is the number of customers\nthat match every filter (not the size of one page).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TenantScope"
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["pending", "active", "suspended", "closing", "closed"]
            }
          },
          {
            "name": "type",
            "in": "query",
            "required": false,
            "description": "`individual` or `business` (Core's list types b2c_individual,\nb2b_standard and b2b_enterprise are accepted as aliases). Anything\nelse is a 400.\n",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "Case-insensitive text found in the name, company or legal name,\ne-mail, phone, tax, VAT or registration number, ids, city, street\nor postcode. Taken literally (no wildcards); at most 200 characters.\n",
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          },
          {
            "name": "kyc_status",
            "in": "query",
            "required": false,
            "description": "KYC (KYB) status. Anything else is a 400.",
            "schema": {
              "type": "string",
              "enum": [
                "pending",
                "in_review",
                "verified",
                "rejected",
                "expired"
              ]
            }
          },
          {
            "name": "screening_status",
            "in": "query",
            "required": false,
            "description": "Screening status. Anything else is a 400.",
            "schema": {
              "type": "string",
              "enum": ["not_screened", "clear", "pending_review", "blocked"]
            }
          },
          {
            "name": "risk_level",
            "in": "query",
            "required": false,
            "description": "Risk level. Anything else is a 400.",
            "schema": {
              "type": "string",
              "enum": ["low", "medium", "high", "prohibited"]
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "description": "The column the page is sorted by: `name` (the display name, case\ninsensitive), `status` and `kyc_status` (lifecycle order), `type`,\n`risk` (low, medium, high, prohibited) or `created_at`. Every sort\nends with the id, so pages neither repeat nor skip a customer.\n",
            "schema": {
              "type": "string",
              "enum": [
                "created_at",
                "name",
                "status",
                "kyc_status",
                "type",
                "risk"
              ],
              "default": "created_at"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["asc", "desc"],
              "default": "desc"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 20
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Customer list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "customers": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Customer"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createCustomer",
        "tags": ["Customers"],
        "summary": "Onboard new customer (individual or business entity)",
        "description": "Creates a new customer record in `pending` status within the tenant\nscope. For individual customers, collects personal identification data\n(name, date of birth, nationality, address) for customer due diligence.\nFor business entities, captures legal name, registration number, VAT ID,\nlegal form, and incorporation date. The `metadata` and `external_refs`\nJSONB fields support tenant-specific extensions (e.g. ERP references,\nexternal KYC provider IDs).\n\n`owner_member` (identity-api only, `X-Service-Key` acting for nobody):\nfor a `business`, the customer and one `owner` member (status\n`active`, accepted now) are written in one transaction; neither is\nwritten when either insert fails. The member name is `name`, else\n`first_name last_name`, else the e-mail. Any other caller sending\n`owner_member` gets 400 `owner_member_service_only`; an individual\ngets 400 `owner_member_business_only`; a malformed object 400\n`invalid_owner_member`. Customer JWTs get 403 on this route.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCustomerRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Customer created. With `owner_member`, the body also carries\n`owner_member: {id, email, role: \"owner\", status: \"active\"}`.\n"
          },
          "400": {
            "description": "Invalid input, or `owner_member` refused:\n`{\"error\":\"owner_member_service_only\"}`,\n`{\"error\":\"owner_member_business_only\"}`,\n`{\"error\":\"invalid_owner_member\"}`.\n"
          },
          "403": {
            "description": "Customer JWT (staff and service route)."
          },
          "409": {
            "description": "E-mail or company already registered in the tenant, or `tenant_customer_limit`: the bank has reached its maximum of customers (DEC-0042)."
          }
        }
      }
    },
    "/api/v1/customers/ensure": {
      "post": {
        "operationId": "ensureCustomer",
        "tags": ["Customers"],
        "summary": "Idempotent customer provisioning with explicit ID",
        "description": "Creates a customer record if it does not already exist. Used by the\nCustomer Portal BFF session route when the identity-api user exists\nbut the finance-api customer record does not (e.g. after a finance DB\nreset). Returns the existing customer if one with the given ID already\nexists. The customer is created in `pending` status with `pending`\nKYC status.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["id", "tenant_id", "email"],
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Customer ID (from identity-api)"
                  },
                  "tenant_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "email": {
                    "type": "string",
                    "format": "email"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Customer already exists (returned as-is)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Customer"
                }
              }
            }
          },
          "201": {
            "description": "Customer created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Customer"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/customers/display-names": {
      "post": {
        "operationId": "getCustomerDisplayNames",
        "tags": ["Customers"],
        "summary": "Display names of up to 200 customers in one read",
        "description": "Core-Bank names the customers of a list (closed alerts, list hits,\nthe alert queue) with one request instead of one\n`GET /api/v1/customers/{customerId}` per row. One statement under\nthe request's tenant: `WHERE tenant_id = $1 AND id = ANY($2)`.\n\nThe display name is the company name, else first and last name,\nelse the legal name. An unknown id, another bank's customer or a\ncustomer without any name is absent from `names`; repeated ids\ncount once. `tenant_id` must be the request's tenant (the session's\ninside a cell, `X-Tenant-ID` in the platform scope): another is 403\n`tenant_mismatch`. The readers of a customer read it (every cell\nrole and the platform); support roles and customers do not.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["tenant_id", "ids"],
                "properties": {
                  "tenant_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "ids": {
                    "type": "array",
                    "maxItems": 200,
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The names found, keyed by customer id",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "names": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`invalid_body`, `tenant_required`, `invalid_tenant`,\n`ids_required`, `too_many_ids` (more than 200) or `invalid_id`\n(an id that is not a UUID).\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "`tenant_mismatch`, or a role that may not read customers",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/customers/{customerId}": {
      "get": {
        "operationId": "getCustomer",
        "tags": ["Customers"],
        "summary": "Get customer by ID",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          }
        ],
        "responses": {
          "200": {
            "description": "Customer details (includes address, phone, tax_id, KYC fields)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Customer"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateCustomer",
        "tags": ["Customers"],
        "summary": "Update customer identity or business data",
        "description": "Partially updates customer fields. Supports 21 mutable fields including\npersonal data, address, tax identification, and business registration\ndetails. Changes to identity fields (name, date of birth, nationality)\nmay trigger re-verification under ongoing due diligence. All updates\nare recorded in the immutable audit trail.\n\nName fields (`first_name`, `last_name`, `company_name` / `name`):\na blank value (empty or only whitespace) counts as not sent and the\nstored name stays, the same rule as the phone's self-service fields;\na real name is trimmed. A name that breaks the name rules is 400\n`{\"error\":\"invalid_field\",\"field\":\"first_name\"}` (or `last_name`,\n`company_name`). With a customer JWT, a field the bank keeps (legal\nname, company name, address, tax and registration data, birth data,\nemail) is 400 when sent with a value; sent blank it counts as not\nsent and the stored value stays.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateCustomerRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Customer updated"
          },
          "400": {
            "description": "`{\"error\":\"invalid_field\",\"field\":\"<name field>\"}` for a name\nthat breaks the name rules; otherwise an error message.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/customers/{customerId}/activate": {
      "post": {
        "operationId": "activateCustomer",
        "tags": ["Customers"],
        "summary": "Activate customer (staff; verified KYC and clear screening)",
        "description": "Moves a pending or suspended customer to active and thaws its\nwallets. Refused unless KYC is verified and screening is clear. The\nofficer is the session; a service call names the officer in\n`activated_by`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["reason"],
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 10,
                    "maxLength": 2000,
                    "description": "Why the customer is activated (audit log)"
                  },
                  "activated_by": {
                    "type": "string",
                    "description": "Officer, for a service call without a session"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Customer activated. `thaw` is `held` when a compliance stop (a\nfreeze case, a SAR hold) keeps the wallets frozen.\n",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": ["active"]
                    },
                    "thaw": {
                      "type": "string",
                      "enum": ["thawed", "held"]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Body missing, or reason shorter than 10 characters"
          },
          "403": {
            "description": "Staff session without an officer identity"
          },
          "409": {
            "description": "`{\"error\":\"kyc_not_verified\"}`, `{\"error\":\"edd_not_approved\"}` (an\nEDD review of a confirmed PEP is not approved, migration 294),\n`{\"error\":\"screening_not_clear\"}`, or the customer is not pending\nor suspended\n"
          }
        }
      }
    },
    "/api/v1/customers/{customerId}/suspend": {
      "post": {
        "operationId": "suspendCustomer",
        "tags": ["Customers"],
        "summary": "Suspend customer (compliance or fraud hold)",
        "description": "Suspends the customer and freezes its wallets. A staff session gives\nthe officer's reason (10 to 2000 characters): it is written to the\nlifecycle audit row and is the reason of the wallet freeze. A service\ncall acting for nobody may omit it.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 10,
                    "maxLength": 2000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Customer suspended"
          },
          "400": {
            "description": "`{\"error\":\"customer_reason_required\"}`: a staff session without a reason of 10 to 2000 characters"
          }
        }
      }
    },
    "/api/v1/customers/{customerId}/close": {
      "post": {
        "operationId": "closeCustomer",
        "tags": ["Customers"],
        "summary": "Close customer (off-boarding, terminal state)",
        "description": "Ends the customer relationship after the notice period. A staff\nsession gives the officer's reason (10 to 2000 characters), written to\nthe lifecycle audit row; the closure workflow's service call may omit\nit.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 10,
                    "maxLength": 2000
                  },
                  "operator_id": {
                    "type": "string",
                    "description": "Closure workflow only"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Customer closed"
          },
          "400": {
            "description": "`{\"error\":\"customer_reason_required\"}`: a staff session without a reason of 10 to 2000 characters"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          }
        }
      }
    },
    "/api/v1/customers/{customerId}/initiate-closure": {
      "post": {
        "operationId": "initiateCustomerClosure",
        "tags": ["Customers"],
        "summary": "Start ending the customer relationship (notice period)",
        "description": "Moves an active or suspended customer to `closing` with a deadline.\nStaff give a `reason_category` and a reason of 10 to 2000 characters.\nWhen the bank ends the relationship in the ordinary way\n(`business_decision`, `inactivity`, `terms_violation`,\n`regulatory_requirement`), `notice_days` must reach the bank's\nclosure policy (60 days or more). AML categories use the\npolicy's AML notice; the customer's own request (`customer_request`)\nhas no bank notice floor.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 10,
                    "maxLength": 2000
                  },
                  "reason_category": {
                    "type": "string",
                    "enum": [
                      "business_decision",
                      "inactivity",
                      "terms_violation",
                      "regulatory_requirement",
                      "aml_derisking",
                      "aml_pep_risk",
                      "fraud_suspicion",
                      "sanctions_match",
                      "customer_request"
                    ]
                  },
                  "notice_days": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 3650
                  },
                  "initiated_by": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Closure started",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "status": {
                      "type": "string",
                      "enum": ["closing"]
                    },
                    "closure_deadline_at": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`{\"error\":\"customer_reason_required\"}` or\n`{\"error\":\"closure_category_required\"}` (staff),\n`{\"error\":\"closure_category_customer_only\"}` (staff sent\n`customer_request`, which only the customer's own request uses),\nor notice_days outside 0..3650\n"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "description": "`{\"error\":\"closure_notice_too_short\"}`: below the bank's closure policy notice"
          }
        }
      }
    },
    "/api/v1/customers/{customerId}/closure-notice": {
      "get": {
        "operationId": "getCustomerClosureNotice",
        "tags": ["Customers"],
        "summary": "Shortest notice for the bank's ordinary closure of a customer",
        "description": "Staff only. The bank's active closure policy notice (60 days or more)\nand the statutory months of the bank's regime, and `min_notice_days`,\nthe larger of the policy's days and 31 days per statutory month:\nthe shortest notice Core's closure dialog offers. initiate-closure\nrefuses less (422 `closure_notice_too_short`).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          }
        ],
        "responses": {
          "200": {
            "description": "The notice floor",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "policy_notice_days",
                    "statutory_months",
                    "min_notice_days"
                  ],
                  "properties": {
                    "policy_notice_days": {
                      "type": "integer"
                    },
                    "statutory_months": {
                      "type": "integer"
                    },
                    "min_notice_days": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Not a staff session"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/customers/{customerId}/provision-account": {
      "post": {
        "operationId": "provisionCustomerAccount",
        "tags": ["Customers"],
        "summary": "Provision wallet + IBAN for customer (onboarding)",
        "description": "Creates a wallet (with ledger engine account), generates an IBAN\nfor the resolved country, and links them. Currency and country are\nresolved from the request body, falling back to the tenant's default\ncurrency and jurisdiction. Used during customer onboarding after KYC\napproval. Note: `/register` and `/authenticate` are deprecated\n(BR-EF-018) \u2014 use identity-api instead.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "default": "Main Wallet",
                    "description": "Wallet display name"
                  },
                  "currency": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 3,
                    "description": "ISO 4217 (resolved from tenant if omitted)"
                  },
                  "country": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 2,
                    "description": "ISO 3166-1 alpha-2 (resolved from tenant if omitted)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Wallet + IBAN provisioned",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "iban": {
                      "type": "string",
                      "example": "DE89370400440532013000"
                    },
                    "account_name": {
                      "type": "string"
                    },
                    "currency": {
                      "type": "string"
                    },
                    "country": {
                      "type": "string"
                    },
                    "customer_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "wallet_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "status": {
                      "type": "string",
                      "enum": ["active"]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          }
        }
      }
    },
    "/api/v1/customers/{customerId}/accounts": {
      "get": {
        "operationId": "listCustomerAccounts",
        "tags": ["Customers"],
        "summary": "List accounts for customer (IBAN registry)",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          }
        ],
        "responses": {
          "200": {
            "description": "Customer accounts"
          }
        }
      }
    },
    "/api/v1/customers/{customerId}/wallets": {
      "get": {
        "operationId": "listCustomerWallets",
        "tags": ["Wallets"],
        "summary": "List active wallets for customer (excludes closed)",
        "description": "Returns all non-closed wallets for the specified customer, joined with\nIBAN data from finance_iban_registry. Closed wallets are excluded from\nthis endpoint \u2014 use the admin `GET /api/v1/wallets` endpoint to see all\nwallets including closed ones. Results are ordered with primary wallets\nfirst (`is_primary DESC`), then by creation date. Each wallet includes\nits IBAN, currency, status, customer_id, and is_primary flag, plus\n`main_currency` and a per-account `is_main` flag in `account_ids`:\nonly the primary wallet's own-currency account is Main. Each\n`account_ids` entry also carries that currency account's receiving\ndetails: `iban`, `bic`, `account_number`, `routing_number` (US\ndetails for USD) and `bank_name` (DEC-0015). The wallet-level `iban`\nstays the wallet currency's IBAN.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          }
        ],
        "responses": {
          "200": {
            "description": "Active wallets for customer",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "wallets": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Wallet"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/customers/{customerId}/provisioning-defaults": {
      "get": {
        "operationId": "getProvisioningDefaults",
        "tags": ["Wallets"],
        "summary": "Get resolved provisioning defaults for customer",
        "description": "Returns the resolved default currency and country for wallet\nprovisioning, based on the customer's tenant and jurisdiction\nconfiguration. Resolution order: tenant.default_currency >\njurisdiction_profile.default_currency > EUR fallback.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          }
        ],
        "responses": {
          "200": {
            "description": "Provisioning defaults",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "currency": {
                      "$ref": "#/components/schemas/Currency"
                    },
                    "country": {
                      "type": "string",
                      "example": "DE"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/customers/{customerId}/members": {
      "get": {
        "operationId": "listCustomerMembers",
        "tags": ["Customers"],
        "summary": "List customer members",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          }
        ],
        "responses": {
          "200": {
            "description": "Member list"
          }
        }
      },
      "post": {
        "operationId": "addCustomerMember",
        "tags": ["Customers"],
        "summary": "Add member to customer",
        "description": "Customer JWT: owner (or role `customer`) only; `admin` and\n`accounting` get 403 `{\"error\":\"forbidden_role\"}`, an impersonation\nsession 403 `{\"error\":\"read_only_session\"}`. A customer JWT cannot\nassign `owner` (403 `{\"error\":\"owner_not_assignable\"}`). The owner\nrow is never changed or removed here (409\n`{\"error\":\"owner_protected\"}`, every caller).\n\nStrong customer authentication (0.34.0, DEC-0039): a customer JWT\npasses the SCA gate of `POST /api/v1/transfers` with `kind`\n`account_change` (identity-api challenge kind) and no exemptions;\n`X-SCA-Token` and the answers as there. The intent hashes\n`FERNEL-ACCOUNT-INTENT-V1`, `tenant:<uuid>`, `customer:<uuid>`,\n`action:member_add`, `member:<the email, lower-case>` and `body:<lower-case hex SHA-256 of the\nraw request body>`, joined by `\\n`. A code is spent once (403\n`sca_token_used` again).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          },
          {
            "name": "X-SCA-Token",
            "in": "header",
            "schema": {
              "type": "string"
            },
            "description": "Customer callers (DEC-0039), as on POST /api/v1/transfers."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["email", "name"],
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "name": {
                    "type": "string"
                  },
                  "role": {
                    "type": "string",
                    "enum": ["owner", "admin", "accounting"],
                    "default": "admin"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Member added"
          },
          "403": {
            "description": "`forbidden_role`, `read_only_session` or `owner_not_assignable` (customer JWT); SCA (0.34.0): `SCA required` / `Invalid SCA token` as on POST /api/v1/transfers"
          },
          "409": {
            "description": "Member already exists; `sca_busy`"
          },
          "503": {
            "description": "`sca_unavailable` (0.34.0)"
          }
        }
      }
    },
    "/api/v1/customers/{customerId}/members/{memberId}": {
      "patch": {
        "operationId": "updateCustomerMember",
        "tags": ["Customers"],
        "summary": "Update member role",
        "description": "Customer JWT: owner (or role `customer`) only; `admin` and\n`accounting` get 403 `{\"error\":\"forbidden_role\"}`, an impersonation\nsession 403 `{\"error\":\"read_only_session\"}`. A customer JWT cannot\nassign `owner` (403 `{\"error\":\"owner_not_assignable\"}`). The owner\nrow is never changed or removed here (409\n`{\"error\":\"owner_protected\"}`, every caller).\n\nStrong customer authentication (0.34.0, DEC-0039): a customer JWT\npasses the SCA gate of `POST /api/v1/transfers` with `kind`\n`account_change` (identity-api challenge kind) and no exemptions;\n`X-SCA-Token` and the answers as there. The intent hashes\n`FERNEL-ACCOUNT-INTENT-V1`, `tenant:<uuid>`, `customer:<uuid>`,\n`action:member_role`, `member:<memberId>` and `body:<lower-case hex SHA-256 of the\nraw request body>`, joined by `\\n`. A code is spent once (403\n`sca_token_used` again).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          },
          {
            "$ref": "#/components/parameters/MemberId"
          },
          {
            "name": "X-SCA-Token",
            "in": "header",
            "schema": {
              "type": "string"
            },
            "description": "Customer callers (DEC-0039), as on POST /api/v1/transfers."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["role"],
                "properties": {
                  "role": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Role updated"
          },
          "403": {
            "description": "`forbidden_role`, `read_only_session` or `owner_not_assignable` (customer JWT); SCA (0.34.0): `SCA required` / `Invalid SCA token` as on POST /api/v1/transfers"
          },
          "409": {
            "description": "`owner_protected`: the owner row is not changed here; `sca_busy`"
          },
          "503": {
            "description": "`sca_unavailable` (0.34.0)"
          }
        }
      },
      "delete": {
        "operationId": "removeCustomerMember",
        "tags": ["Customers"],
        "summary": "Remove member",
        "description": "Customer JWT: owner (or role `customer`) only; `admin` and\n`accounting` get 403 `{\"error\":\"forbidden_role\"}`, an impersonation\nsession 403 `{\"error\":\"read_only_session\"}`. A customer JWT cannot\nassign `owner` (403 `{\"error\":\"owner_not_assignable\"}`). The owner\nrow is never changed or removed here (409\n`{\"error\":\"owner_protected\"}`, every caller).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          },
          {
            "$ref": "#/components/parameters/MemberId"
          }
        ],
        "responses": {
          "200": {
            "description": "Member removed"
          },
          "403": {
            "description": "`forbidden_role` or `read_only_session` (customer JWT)"
          },
          "409": {
            "description": "`owner_protected`: the owner is not removed"
          }
        }
      }
    },
    "/api/v1/customers/{customerId}/kyc/submit": {
      "post": {
        "operationId": "submitKyc",
        "tags": ["Customers"],
        "summary": "Submit customer for KYC/CDD review",
        "description": "Transitions customer KYC status to `in_review`. Optionally attach\ncompliance officer notes and a risk score (0-100) for enhanced due\ndiligence (EDD) flagging. Risk scores above the\nconfigured threshold trigger additional verification requirements.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "notes": {
                    "type": "string"
                  },
                  "risk_score": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 100
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "KYC submitted for review"
          }
        }
      }
    },
    "/api/v1/customers/{customerId}/kyc/approve": {
      "post": {
        "operationId": "approveKyc",
        "tags": ["Customers"],
        "summary": "Approve KYC verification (compliance officer action)",
        "description": "Approves the customer's identity verification, transitioning KYC status\nto `verified`. This action is restricted to `mlro` (and the platform\nscope's `super_admin`). The approval is recorded in the KYC audit history with\nthe approving officer's identity for AML record keeping.\nThe officer is the session; a service call names it in `reviewer`.\nRefused while the customer's screening is not clear: a manual approval\nnever opens a wallet the automatic path would hold back. Refused without\nidentity evidence. A business also passes the ES multi-source UBO\ncheck, from the customer's own tenant.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["notes"],
                "properties": {
                  "notes": {
                    "type": "string",
                    "minLength": 10,
                    "maxLength": 2000,
                    "description": "The officer's reason for the approval (KYC audit history)"
                  },
                  "risk_score": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 100
                  },
                  "reviewer": {
                    "type": "string",
                    "description": "Officer, for a service call without a session"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "KYC approved; a pending customer becomes active and gets its default wallet"
          },
          "400": {
            "description": "`{\"error\":\"kyc_reason_required\"}`: notes missing or shorter than 10 characters"
          },
          "403": {
            "description": "Role may not approve KYC, or a staff session without an officer identity"
          },
          "409": {
            "description": "`{\"error\":\"edd_not_approved\"}` (an EDD review of a confirmed PEP is\nnot approved, migration 294),\n`{\"error\":\"screening_not_clear\"}`, `{\"error\":\"identity_evidence_missing\"}`\n(an individual's latest decided identity session is not approved,\nor is a manual check without the person's data),\n`{\"error\":\"tenant_unresolved\"}`, or an invalid KYC status transition\n"
          },
          "422": {
            "description": "`{\"error\":\"ubo_multi_source_required\"}`: an ES business without a\nUBO source other than the register\n"
          }
        }
      }
    },
    "/api/v1/customers/{customerId}/kyc/reject": {
      "post": {
        "operationId": "rejectKyc",
        "tags": ["Customers"],
        "summary": "Reject KYC verification (compliance officer action)",
        "description": "Rejects the customer's identity verification. The customer remains in\n`rejected` state and cannot open accounts or transact until a new KYC\nsubmission is approved. Restricted to `mlro` (and the platform\nscope). Staff give a reason category and a reason of 10 to 2000\ncharacters; both are recorded in the KYC history.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["notes", "reason_code"],
                "properties": {
                  "notes": {
                    "type": "string",
                    "minLength": 10,
                    "maxLength": 2000,
                    "description": "The officer's reason (KYC history)"
                  },
                  "reason_code": {
                    "type": "string",
                    "enum": [
                      "document_invalid",
                      "identity_mismatch",
                      "face_match_failed",
                      "incomplete_information",
                      "fraud_suspected",
                      "outside_risk_appetite",
                      "other"
                    ]
                  },
                  "reviewer": {
                    "type": "string",
                    "description": "Officer, for a service call without a session"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "KYC rejected"
          },
          "400": {
            "description": "`{\"error\":\"kyc_reason_required\"}` or\n`{\"error\":\"kyc_reject_category_required\"}`\n"
          },
          "403": {
            "description": "`forbidden_role` (staff route gate, DEC-0043); Role may not reject KYC, or a staff session without an officer identity"
          },
          "409": {
            "description": "Invalid KYC status transition"
          }
        }
      }
    },
    "/api/v1/customers/{customerId}/kyc/history": {
      "get": {
        "operationId": "getKycHistory",
        "tags": ["Customers"],
        "summary": "Retrieve KYC verification audit history",
        "description": "Returns the complete KYC event history for regulatory reporting and\ncompliance review. Includes all status transitions, officer actions,\nrisk score changes, and timestamps. Kept at least for the AML\nrecord-keeping period of the tenant's jurisdiction. A rejection names\nits `reason_code` (empty otherwise).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          }
        ],
        "responses": {
          "200": {
            "description": "KYC event history"
          }
        }
      }
    },
    "/api/v1/customers/{customerId}/kyc/start": {
      "post": {
        "operationId": "mobileKycStart",
        "tags": ["Customers"],
        "summary": "Start a KYC/KYB session for mobile (direct finance-api call)",
        "description": "Creates an Identomat verification session for the authenticated customer.\nResolves the active KYC/KYB configuration for the tenant, calls the\nIdentomat `/begin/` endpoint, persists the session record, and dispatches\nthe `KycVerification` background workflow (fire-and-forget with 120 s initial\ndelay). Returns the session token and widget URL for the mobile SDK.\nJWT ownership check \u2014 token subject must match `customerId`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "locale": {
                    "type": "string",
                    "description": "BCP-47 locale hint for the widget language (default \"en\")",
                    "example": "de"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Session created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "sessionId",
                    "sessionToken",
                    "widgetUrl",
                    "sessionType",
                    "expiresMinutes"
                  ],
                  "properties": {
                    "sessionId": {
                      "type": "string",
                      "format": "uuid",
                      "description": "Internal finance_kyc_sessions record ID"
                    },
                    "sessionToken": {
                      "type": "string",
                      "description": "Identomat provider session token (pass to mobile SDK)"
                    },
                    "widgetUrl": {
                      "type": "string",
                      "format": "uri",
                      "description": "Identomat widget URL for WebView embed"
                    },
                    "sessionType": {
                      "type": "string",
                      "enum": ["kyc", "kyb"]
                    },
                    "expiresMinutes": {
                      "type": "integer",
                      "description": "Session TTL in minutes as configured on the tenant"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "No active KYC configuration found for this tenant"
          },
          "503": {
            "description": "KYC provider not configured or temporarily unavailable"
          }
        }
      }
    },
    "/api/v1/customers/{customerId}/kyc/status": {
      "get": {
        "operationId": "mobileKycStatus",
        "tags": ["Customers"],
        "summary": "Poll KYC session status (mobile)",
        "description": "Returns the latest KYC session fields plus the customer-level `kyc_status`.\nMobile polls this endpoint after the Identomat SDK signals completion until\n`customerKycStatus` reaches `verified` or `rejected`. Returns `{\"status\":\"none\"}`\nwhen no session exists yet.\nJWT ownership check \u2014 token subject must match `customerId`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          }
        ],
        "responses": {
          "200": {
            "description": "Current KYC session state",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["status", "customerKycStatus"],
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "none",
                        "created",
                        "in_review",
                        "approved",
                        "rejected",
                        "expired"
                      ],
                      "description": "KYC session status; \"none\" when no session exists"
                    },
                    "sessionType": {
                      "type": "string",
                      "enum": ["kyc", "kyb"]
                    },
                    "widgetUrl": {
                      "type": "string",
                      "format": "uri"
                    },
                    "sessionToken": {
                      "type": "string"
                    },
                    "expiresAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "rejectReason": {
                      "type": "string"
                    },
                    "customerKycStatus": {
                      "type": "string",
                      "enum": ["pending", "in_review", "verified", "rejected"],
                      "description": "Customer-level KYC status (source of truth for access gating)"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/customers/{customerId}/kyc/complete": {
      "post": {
        "operationId": "mobileKycComplete",
        "tags": ["Customers"],
        "summary": "Signal KYC widget completion (mobile)",
        "description": "Called by the mobile app when the Identomat SDK fires its completion\ncallback. Transitions the customer `kyc_status` to `in_review` and\nre-dispatches the `KycVerification` background workflow with zero initial\ndelay for eager result polling (20 attempts, 30 s interval).\nIdempotent \u2014 if the session is already in a terminal state the current\nstatus is returned without modification.\nJWT ownership check \u2014 token subject must match `customerId`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          }
        ],
        "responses": {
          "202": {
            "description": "Completion acknowledged; KYC verification workflow dispatched",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["status", "kycStatus"],
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "in_review",
                        "approved",
                        "rejected",
                        "expired",
                        "already_completed"
                      ]
                    },
                    "kycStatus": {
                      "type": "string",
                      "enum": ["pending", "in_review", "verified", "rejected"]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "No KYC session found for this customer"
          }
        }
      }
    },
    "/api/v1/customers/{customerId}/transactions": {
      "get": {
        "operationId": "listCustomerTransactions",
        "tags": ["Customers"],
        "summary": "List all transactions across customer wallets",
        "description": "Returns transactions from all non-closed wallets of this customer.\nUsed by the customer portal and the mobile app for the unified\ntransaction feed.\n\nKeyset paging (DEC-0029): newest first, `created_at` descending then\nthe row id descending. Follow `next_cursor` while `has_more` is\ntrue; a page never skips or repeats a row, also when rows share\n`created_at`. A filter change starts from the first page.\n\n`amount` is signed: negative for a debit of the customer's account,\npositive for a credit. `from_name` / `to_name` name the parties as\nthe customer sees them (see `Transfer`): a platform account is never\nnamed; a credit from one shows the payer recorded as\n`counterparty_name` on `POST /api/v1/transfers`, else `\"\"`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          },
          {
            "$ref": "#/components/parameters/HistoryLimit"
          },
          {
            "$ref": "#/components/parameters/HistoryCursor"
          },
          {
            "$ref": "#/components/parameters/HistoryAccountId"
          },
          {
            "$ref": "#/components/parameters/HistoryDirection"
          },
          {
            "$ref": "#/components/parameters/HistoryFrom"
          },
          {
            "$ref": "#/components/parameters/HistoryTo"
          },
          {
            "$ref": "#/components/parameters/HistoryTzOffset"
          },
          {
            "$ref": "#/components/parameters/HistoryStatus"
          },
          {
            "$ref": "#/components/parameters/HistoryCurrency"
          },
          {
            "$ref": "#/components/parameters/HistoryEventType"
          },
          {
            "$ref": "#/components/parameters/HistoryQuery"
          },
          {
            "$ref": "#/components/parameters/HistoryQueryType"
          },
          {
            "$ref": "#/components/parameters/HistoryAmountMin"
          },
          {
            "$ref": "#/components/parameters/HistoryAmountMax"
          }
        ],
        "responses": {
          "200": {
            "description": "One page of the transaction list",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/HistoryPage"
                    },
                    {
                      "type": "object",
                      "required": ["transfers"],
                      "properties": {
                        "transfers": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Transfer"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HistoryBadRequest"
          },
          "422": {
            "$ref": "#/components/responses/HistorySearchTooBroad"
          },
          "429": {
            "$ref": "#/components/responses/HistorySearchBusy"
          },
          "500": {
            "$ref": "#/components/responses/HistoryFailed"
          },
          "503": {
            "$ref": "#/components/responses/HistoryUnavailable"
          }
        }
      }
    },
    "/api/v1/customers/{customerId}/statement": {
      "get": {
        "operationId": "getCustomerStatement",
        "tags": ["Documents"],
        "summary": "Account statement for a period (PDF, CSV, camt.053, MT940)",
        "description": "All booked and pending movements of the account in the period,\noldest first, in the customer's local days (`tz_offset_minutes`):\ntransfers by `created_at` and card movements of the account (cleared\ncard payments at their clearing, refunds and chargebacks, open holds\nas pending rows; type `card_capture`, `card_refund`,\n`card_authorization`, the merchant as counterparty).\n\nBalances come from the ledger (DEC-0030 implementation notes). For\nan account with the TigerBeetle history flag the opening balance is\nthe posted balance at the start of `from` and the closing balance\nthe posted balance at the end of `to`, from the ledger history\n(TigerBeetle cluster time); when the ledger moved more in the period\nthan the rows show, one row \"Other booked movements\" (type\n`ledger_other`) dated at the end of the period carries the\ndifference. For an account without it (legacy, seeded) the closing\nbalance is the posted balance now minus the net of the completed\nmovements recorded after the period, the opening balance that minus\nthe period's booked net. Either way opening + money in + money out =\nclosing; running balances (PDF, CSV) and OPBD/CLBD, :60F:/:62F:\nfollow from the opening. Pending rows are listed (PDF, CSV) but do\nnot move the balance; camt.053 and MT940 hold booked entries only.\n503 `documents_unavailable` when the ledger or its history cannot\nbe read, or when the ledger does not hold an account that has\nmovement records (never figures from the records alone). A\nreference that is a full ledger account id of the transfer's own\naccounts (or any on a fee booking) is left empty.\n\n- `pdf`: A4, tenant brand colour and name, holder, IBAN, BIC as the\n  wallet shows it (left out only when unknown), summary box, table with a running balance, \"Page x of\n  y\", legal footer by licence pack (Art. 1b depositor protection\n  notice for Swiss FinTech tenants, safeguarding notice for EMIs).\n  Helvetica with WinAnsi: en, de, es, pt; `ar` renders English. A\n  description finance-api wrote itself (\"FX conversion (debit)\",\n  \"Platform fee\", \"Internal transfer\", ...) or an empty one reads as\n  a type label in the document's language (by `event_type`); a\n  customer's own text is shown as entered.\n- `csv`: UTF-8 with BOM, comma, CRLF, RFC 4180, English header\n  `date,value_date,type,description,counterparty,reference,amount,currency,fee,balance,status,transaction_id,account`;\n  ISO dates, dot decimal, signed amounts, the stored description\n  unchanged; `balance` only for one account. Several `account_id` (or none: all accounts) are merged by\n  time without a balance.\n- `camt053`: camt.053.001.08, OPBD and CLBD, one `Ntry` per booked\n  movement.\n- `mt940`: `:20: :25: :28C: :60F: :61: :86: :62F:`, CRLF, SWIFT X\n  character set.\n\nA customer JWT may read its own customer and accounts only (every\n`account_id` is checked). Staff: the account must belong to the\ncustomer in the path.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          },
          {
            "$ref": "#/components/parameters/StatementAccountId"
          },
          {
            "$ref": "#/components/parameters/StatementFrom"
          },
          {
            "$ref": "#/components/parameters/StatementTo"
          },
          {
            "$ref": "#/components/parameters/StatementFormat"
          },
          {
            "$ref": "#/components/parameters/DocumentLocale"
          },
          {
            "$ref": "#/components/parameters/HistoryTzOffset"
          }
        ],
        "responses": {
          "200": {
            "description": "The statement file",
            "headers": {
              "Content-Disposition": {
                "description": "`attachment; filename=\"statement-<IBAN or account>-<from>_<to>.<pdf|csv|xml|sta>\"` (several accounts: `statement-all-...csv` or `statement-accounts-...csv`)",
                "schema": {
                  "type": "string"
                }
              },
              "X-Statement-Rows": {
                "description": "Rows in the file (camt.053 and MT940 count booked entries)",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              },
              "application/xml": {
                "schema": {
                  "type": "string"
                }
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/DocumentBadRequest"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/DocumentNotFound"
          },
          "422": {
            "$ref": "#/components/responses/DocumentUnprocessable"
          },
          "429": {
            "$ref": "#/components/responses/DocumentBusy"
          },
          "500": {
            "$ref": "#/components/responses/DocumentFailed"
          },
          "503": {
            "$ref": "#/components/responses/DocumentUnavailable"
          }
        }
      }
    },
    "/api/v1/customers/{customerId}/statement/summary": {
      "get": {
        "operationId": "getCustomerStatementSummary",
        "tags": ["Documents"],
        "summary": "Statement figures for a preview before download",
        "description": "Same parameters and rules as the statement, without `format`. One\n`account_id`: one object. Several or none (all accounts): `accounts`.\nAmounts in minor units; `money_out` is negative; `count` counts every\nmovement row (pending included; the \"Other booked movements\" row is\nnot a movement and not counted).\nBalances come from the ledger for every account listed, as in the\nstatement; `balance_basis` says how (`ledger`: the ledger history\nat the start of `from` and the end of `to`; `derived`: an account\nwithout the history flag, or a ledger without history such as\n`TB_MOCK`, the posted balance now minus the recorded movements\nafter `to`). For a period that ends today\n`closing_balance` is the posted balance. `other_booked` is what the\nledger moved in the period beyond the rows (0: nothing). 503\n`documents_unavailable` as for the statement.\n\n`interval=week` adds `periods` to every account: the period cut at\nthe ISO weeks (Monday to Sunday) of the customer's local days\n(`tz_offset_minutes`), the first and the last week cut to `from`\nand `to`, oldest first, at most 13 weeks (more: `422\ninvalid_period`). Each week has its booked `money_in`, `money_out`\nand `closing_balance`; the first week opens at `opening_balance`,\neach next one at the previous `closing_balance`, so opening +\n`money_in` + `money_out` = `closing_balance` per week, the weeks add\nup to the account's `money_in` and `money_out`, and the last\n`closing_balance` is the account's. A week without booked movements\nis listed with 0. The weeks come from the same rows and ledger read\nas the account's figures (no read per week); the \"Other booked\nmovements\" amount counts in the last week. Without `interval` the\nanswer is unchanged (no `periods`).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          },
          {
            "$ref": "#/components/parameters/StatementAccountId"
          },
          {
            "$ref": "#/components/parameters/StatementFrom"
          },
          {
            "$ref": "#/components/parameters/StatementTo"
          },
          {
            "$ref": "#/components/parameters/HistoryTzOffset"
          },
          {
            "$ref": "#/components/parameters/StatementInterval"
          }
        ],
        "responses": {
          "200": {
            "description": "Opening and closing balance, money in and out, count",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/StatementSummary"
                    },
                    {
                      "$ref": "#/components/schemas/StatementSummaryList"
                    }
                  ]
                },
                "example": {
                  "account_id": "20000000000000000000000000000032",
                  "currency": "CHF",
                  "from": "2026-09-01",
                  "to": "2026-09-30",
                  "opening_balance": 20000000,
                  "closing_balance": 19951000,
                  "money_in": 1500,
                  "money_out": -50500,
                  "count": 84,
                  "balance_basis": "ledger",
                  "other_booked": 0
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/DocumentBadRequest"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/DocumentNotFound"
          },
          "422": {
            "$ref": "#/components/responses/DocumentUnprocessable"
          },
          "429": {
            "$ref": "#/components/responses/DocumentBusy"
          },
          "500": {
            "$ref": "#/components/responses/DocumentFailed"
          },
          "503": {
            "$ref": "#/components/responses/DocumentUnavailable"
          }
        }
      }
    },
    "/api/v1/customers/{customerId}/transactions/export": {
      "get": {
        "operationId": "exportCustomerTransactions",
        "tags": ["Documents"],
        "summary": "Export a filtered transaction list (CSV, PDF)",
        "description": "The rows of a history view (`GET /customers/{id}/transactions`) with\nthe same filters, parsed by the same function as the history\n(`account_id`, `direction`, `from`, `to`, `tz_offset_minutes`,\n`status` repeatable with the aliases `cancelled` = cancelled +\nvoided, `failed` = failed + rejected, `returned` = returned + a\ntransfer an R-transaction returned, `currency`, `event_type`, `q`,\n`q_type`, `amount_min`, `amount_max`) and the same 400\n`invalid_filter` refusals, without paging (`cursor` and `limit` are\nignored), oldest first. At most 20 000 rows (`422\ntoo_many_rows`). The PDF is a simple list without balances and says\nthat it is not a statement; system descriptions read as type labels\nin its language, as in the statement PDF (the CSV keeps them). File name\n`transactions-<from>_<to>.<csv|pdf>` (`from`: the filter, else the\noldest row; `to`: the filter, else today).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          },
          {
            "$ref": "#/components/parameters/HistoryAccountId"
          },
          {
            "$ref": "#/components/parameters/HistoryDirection"
          },
          {
            "$ref": "#/components/parameters/HistoryFrom"
          },
          {
            "$ref": "#/components/parameters/HistoryTo"
          },
          {
            "$ref": "#/components/parameters/HistoryTzOffset"
          },
          {
            "$ref": "#/components/parameters/HistoryStatus"
          },
          {
            "$ref": "#/components/parameters/HistoryCurrency"
          },
          {
            "$ref": "#/components/parameters/HistoryEventType"
          },
          {
            "$ref": "#/components/parameters/HistoryQuery"
          },
          {
            "$ref": "#/components/parameters/HistoryQueryType"
          },
          {
            "$ref": "#/components/parameters/HistoryAmountMin"
          },
          {
            "$ref": "#/components/parameters/HistoryAmountMax"
          },
          {
            "$ref": "#/components/parameters/ExportFormat"
          },
          {
            "$ref": "#/components/parameters/DocumentLocale"
          }
        ],
        "responses": {
          "200": {
            "description": "The export file",
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                }
              },
              "X-Statement-Rows": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              },
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/DocumentBadRequest"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/DocumentNotFound"
          },
          "422": {
            "$ref": "#/components/responses/DocumentUnprocessable"
          },
          "429": {
            "$ref": "#/components/responses/DocumentBusy"
          },
          "500": {
            "$ref": "#/components/responses/DocumentFailed"
          },
          "503": {
            "$ref": "#/components/responses/DocumentUnavailable"
          }
        }
      }
    },
    "/api/v1/customers/{customerId}/accounts/{accountId}/confirmation": {
      "get": {
        "operationId": "getAccountConfirmation",
        "tags": ["Documents"],
        "summary": "Account confirmation letter (PDF)",
        "description": "Holder name and address, IBAN, BIC as the wallet shows it (the\nregistry row's, else the account metadata's for the IBAN, else the\none the IBAN's national bank code names, e.g. CaixaBank for a Spanish\nIBAN with bank code 2100, and only then the tenant's\n`branding.bank_bic`; left out only when none is known), currency,\nopening date, account status and, with `with_balance=true`, the\navailable balance in the ledger at generation (\"Available balance on\n<date>\": posted credits minus posted and pending debits, as `GET\n/accounts/{id}/balances` reports `available_balance`; the line is\nleft out when the ledger cannot be read); the tenant's legal footer. `accountId` is an\nIBAN registry serial or a ledger account id of this customer.\nFile name `account-confirmation-<IBAN or account>-<date>.pdf`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          },
          {
            "name": "accountId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "with_balance",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "$ref": "#/components/parameters/DocumentLocale"
          },
          {
            "$ref": "#/components/parameters/HistoryTzOffset"
          }
        ],
        "responses": {
          "200": {
            "description": "The letter",
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/DocumentBadRequest"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/DocumentNotFound"
          },
          "429": {
            "$ref": "#/components/responses/DocumentBusy"
          },
          "500": {
            "$ref": "#/components/responses/DocumentFailed"
          },
          "503": {
            "$ref": "#/components/responses/DocumentUnavailable"
          }
        }
      }
    },
    "/api/v1/customers/{customerId}/letters": {
      "get": {
        "operationId": "listCustomerLetters",
        "tags": ["Letters"],
        "summary": "Letters from the bank (newest first)",
        "description": "Letters not removed after retention, newest first. `superseded`: a\nnewer letter replaced it (a new due date); `opened`: the customer\ndownloaded it. Staff reads write `support.letter.viewed`. Rate limit\n60 per minute per customer together with `GET /support/summary` and\n`GET /support/tickets*`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 120
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 30
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Letters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerLetterList"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_cursor`, `invalid_limit`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          },
          "403": {
            "description": "`forbidden_role` (a staff role without support access)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`: no such customer for the caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          },
          "503": {
            "description": "`support_unavailable`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/customers/{customerId}/letters/{letterId}": {
      "get": {
        "operationId": "getCustomerLetter",
        "tags": ["Letters"],
        "summary": "One letter, the stored PDF",
        "description": "The bytes as stored when the letter was issued, never regenerated;\ntheir SHA-256 equals `X-Letter-SHA256` and the stored value (a\nmismatch is never served: 503). Always an attachment\n(`<reference>.pdf`). The customer's first download sets\n`first_opened_at` (not in an impersonated session). Staff downloads\nwrite `support.letter.viewed`. 410 `letter_removed` after the\nretention period. Rate limit 10 per minute per customer, 60 per\nstaff user.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          },
          {
            "name": "letterId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The letter",
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string",
                  "example": "attachment; filename=\"LT-2026-000031.pdf\""
                }
              },
              "X-Letter-SHA256": {
                "schema": {
                  "type": "string",
                  "pattern": "^[0-9a-f]{64}$"
                }
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "403": {
            "description": "`forbidden_role`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          },
          "410": {
            "description": "`letter_removed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          },
          "503": {
            "description": "`support_unavailable` (the document store did not answer or the bytes do not match)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/customers/{customerId}/statement-preferences": {
      "get": {
        "operationId": "getStatementPreferences",
        "tags": ["Documents"],
        "summary": "Statement preferences of the customer",
        "description": "The customer's defaults for statements. Without a stored row the\ndefaults are returned (`pdf`, not signed, no monthly delivery) and\nnothing is written. Clients preselect the statement format from\n`default_format`: `pdf` -> `pdf`, `csv` -> `csv`,\n`xml-v12` / `xml-v08` / `xml-v02` -> `camt053`, `mt940` -> `mt940`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          }
        ],
        "responses": {
          "200": {
            "description": "Preferences",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatementPreferences"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      },
      "patch": {
        "operationId": "updateStatementPreferences",
        "tags": ["Documents"],
        "summary": "Store statement preferences",
        "description": "Upserts the preferences. `signed_stamped_default` is stored as false\nunless `default_format` is `pdf`. The tenant comes from the customer\nrow, never from the request.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "default_format": {
                    "type": "string",
                    "enum": [
                      "pdf",
                      "csv",
                      "xml-v12",
                      "xml-v08",
                      "xml-v02",
                      "mt940"
                    ],
                    "default": "pdf"
                  },
                  "signed_stamped_default": {
                    "type": "boolean",
                    "default": false
                  },
                  "monthly_delivery_enabled": {
                    "type": "boolean",
                    "default": false
                  },
                  "monthly_delivery_hour": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 23,
                    "nullable": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Stored preferences",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatementPreferences"
                }
              }
            }
          },
          "400": {
            "description": "Invalid format or delivery hour"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Customer not found"
          }
        }
      }
    },
    "/api/v1/customers/{customerId}/overview": {
      "get": {
        "operationId": "getCustomerOverview",
        "tags": ["Customers"],
        "summary": "The customer record's summary for staff",
        "description": "What an officer sees at the top of the customer record in Core-Bank\n(UX review 2026-10-07, WP-A), in one read: the risk level and the\nlast KYC decision with its written reason, the screening status and\nwhen the customer was last screened, the accounts by status (the\nfrozen ones with who froze them and since when), pending transfers,\nincoming credits held for their holding period, the last activity,\ntransfers and account changes waiting for a second officer, cards by\nstatus, open helpdesk cases and complaints, and open compliance\nalerts.\n\nStaff sessions only (customers and service calls get 403). What a\nrole does not read elsewhere it does not read here: `compliance`\n(open cases and case freezes) only for the MLRO, the auditor and the\nplatform; `sar_holds` only for the MLRO and the platform; `alerts`\nnot for the CFO; `support.items` only for the bank admin, the MLRO,\nthe auditor and the platform (the counts for every role). A part a\nrole does not read is `null`. Lists hold at most 20 rows; counts are\nexact. A customer of another bank is 404 like an unknown one.\nBalances are the ledger's: `GET /api/v1/wallets/{id}/balances`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          }
        ],
        "responses": {
          "200": {
            "description": "The summary",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerOverview"
                }
              }
            }
          },
          "403": {
            "description": "Not a staff session, or a role the gate refuses"
          },
          "404": {
            "description": "Unknown customer, or one of another bank"
          }
        }
      }
    },
    "/api/v1/customers/{customerId}/limits": {
      "get": {
        "operationId": "getCustomerLimits",
        "tags": ["Customers"],
        "summary": "Limits in force for a customer",
        "description": "The limits that apply to this customer in one currency, resolved\nby priority: the customer's own override, an AML provider's limit,\nthe default of the customer type, the bank's default. Values are\nminor units of `currency`; null means no limit, 0 allows nothing\n(since migration 266). `source` names the row that applies.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          },
          {
            "name": "currency",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "EUR"
            },
            "description": "ISO 4217 code (default EUR; also `X-Currency`)."
          }
        ],
        "responses": {
          "200": {
            "description": "Limits in force with their source",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResolvedCustomerLimits"
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "setCustomerLimitOverride",
        "tags": ["Customers"],
        "summary": "Set the customer's own limits in a currency",
        "description": "Writes the customer's override (limit_type override, enforced by\nthe transfer limit check) in one currency: a new row, or the\ncustomer's live row in that currency turned into the override. An\nAML provider's limit is not overwritten (409\n`aml_provider_limit_exists`). Values: integer minor units >= 0 or\nnull (no limit), all three required, single <= daily <= monthly.\nStaff `bank_admin` (super_admin reads only, DEC-0042); recorded against the admin\nsession's user (a service-key caller: `X-Admin-ID` / `X-User-ID`),\nany other caller 403 `staff_actor_required`. Audited\n(`limit.override_set`, old and new values).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomerLimitOverrideRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The override row",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransactionLimit"
                }
              }
            }
          },
          "400": {
            "description": "`limit_value_required`, `limit_value_invalid`, `limit_order_invalid`, `limit_window_invalid`, `unsupported_currency`, `note_required`"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`aml_provider_limit_exists`; `limit_replace_required`: a windowed override would replace the one in force now, without `replace: true`"
          }
        }
      },
      "delete": {
        "operationId": "deleteCustomerLimitOverrideRetired",
        "tags": ["Customers"],
        "summary": "Retired (405 use_remove)",
        "description": "Overrides are removed with a reason; use `POST .../limits/remove`.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          }
        ],
        "responses": {
          "405": {
            "description": "`use_remove`"
          }
        }
      }
    },
    "/api/v1/customers/{customerId}/limits/remove": {
      "post": {
        "operationId": "deleteCustomerLimitOverride",
        "tags": ["Customers"],
        "summary": "Remove the customer's own limits (soft, with a reason)",
        "description": "Soft-deletes the customer's override in one currency (or in every\ncurrency without `currency`); the bank's default applies again.\nThe rows are kept with `deleted_by` and `delete_reason` and audited\n(`limit.override_removed`). Staff `bank_admin` (super_admin reads only, DEC-0042).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["reason"],
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 1000
                  },
                  "currency": {
                    "type": "string",
                    "example": "EUR"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Removed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "example": "override_removed"
                    },
                    "removed": {
                      "type": "integer"
                    },
                    "reverted_to": {
                      "type": "string",
                      "example": "default"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`note_required`, `unsupported_currency`"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/customers/{customerId}/beneficiaries": {
      "get": {
        "operationId": "listCustomerBeneficiaries",
        "tags": ["Customers"],
        "summary": "List beneficiaries for a customer",
        "description": "Returns saved payment recipients (beneficiaries) belonging to this\ncustomer. Shortcut for `GET /api/v1/beneficiaries?customer_id={id}`.\nA customer JWT gets 403 `forbidden` when `{customerId}` is not the\nJWT `customer_id`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerId"
          }
        ],
        "responses": {
          "200": {
            "description": "Beneficiary list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "beneficiaries": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Beneficiary"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BeneficiaryBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/BeneficiaryForbidden"
          }
        }
      }
    },
    "/api/v1/kyc-config": {
      "get": {
        "operationId": "listKycConfigs",
        "tags": ["KycConfig"],
        "summary": "List KYC verification configurations for a tenant",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Tenant ID to filter configs"
          }
        ],
        "responses": {
          "200": {
            "description": "KYC verification configurations",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "configs": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/KycVerificationConfig"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createKycConfig",
        "tags": ["KycConfig"],
        "summary": "Create a new KYC verification configuration",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["tenant_id", "name"],
                "properties": {
                  "tenant_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "config_type": {
                    "type": "string",
                    "enum": ["kyc", "kyb"],
                    "default": "kyc"
                  },
                  "name": {
                    "type": "string",
                    "maxLength": 100
                  },
                  "provider_config_id": {
                    "type": "string",
                    "maxLength": 50,
                    "description": "KYC provider configuration ID"
                  },
                  "verification_tier": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 3,
                    "default": 1
                  },
                  "auto_approve_enabled": {
                    "type": "boolean",
                    "default": false
                  },
                  "auto_approve_min_similarity": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1,
                    "default": 0.85
                  },
                  "screening_enabled": {
                    "type": "boolean",
                    "default": true
                  },
                  "screening_min_score": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 100,
                    "default": 85
                  },
                  "session_lifetime_minutes": {
                    "type": "integer",
                    "minimum": 5,
                    "maximum": 60,
                    "default": 15
                  },
                  "require_liveness": {
                    "type": "boolean",
                    "default": true
                  },
                  "liveness_type": {
                    "type": "string",
                    "enum": ["passive", "active"],
                    "default": "passive"
                  },
                  "require_proof_of_address": {
                    "type": "boolean",
                    "default": false
                  },
                  "require_selfie_with_id": {
                    "type": "boolean",
                    "default": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Config created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KycVerificationConfig"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          }
        }
      }
    },
    "/api/v1/kyc-config/{configId}": {
      "get": {
        "operationId": "getKycConfig",
        "tags": ["KycConfig"],
        "summary": "Get a specific KYC verification configuration",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "configId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Config detail",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KycVerificationConfig"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "patch": {
        "operationId": "updateKycConfig",
        "tags": ["KycConfig"],
        "summary": "Update a KYC verification configuration",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "configId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "auto_approve_enabled": {
                    "type": "boolean"
                  },
                  "auto_approve_min_similarity": {
                    "type": "number"
                  },
                  "screening_enabled": {
                    "type": "boolean"
                  },
                  "require_liveness": {
                    "type": "boolean"
                  },
                  "is_active": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Config updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KycVerificationConfig"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "delete": {
        "operationId": "deleteKycConfig",
        "tags": ["KycConfig"],
        "summary": "Delete a KYC verification configuration",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "configId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Config deleted"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/kyc-config/session/{customerId}": {
      "get": {
        "operationId": "getKycSession",
        "tags": ["KycConfig"],
        "summary": "Get latest KYC verification session for a customer",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Latest session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KycSession"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "post": {
        "operationId": "createKycSession",
        "tags": ["KycConfig"],
        "summary": "Create a KYC verification session for a customer",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["tenant_id", "session_token", "session_type"],
                "properties": {
                  "tenant_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "config_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "session_token": {
                    "type": "string"
                  },
                  "session_type": {
                    "type": "string",
                    "enum": ["kyc", "kyb"]
                  },
                  "widget_url": {
                    "type": "string"
                  },
                  "expires_minutes": {
                    "type": "integer",
                    "default": 15
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Session created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KycSession"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/kyc-config/sessions/stats": {
      "get": {
        "operationId": "getKycSessionStats",
        "tags": ["KycConfig"],
        "summary": "KYC session statistics by status",
        "description": "Returns aggregate counts of KYC sessions grouped by status\n(e.g. pending, completed, expired, failed). Used by the admin\ndashboard for KYC pipeline overview.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Session statistics",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "stats": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "status": {
                            "type": "string"
                          },
                          "count": {
                            "type": "integer"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/kyc-config/sessions/all": {
      "get": {
        "operationId": "listAllKycSessions",
        "tags": ["KycConfig"],
        "summary": "List recent KYC sessions across all customers",
        "description": "Returns recent KYC sessions globally, optionally filtered by status.\nUsed by admin dashboard for monitoring the KYC verification pipeline.\nEach session carries the customer's name and type; `total` counts\nevery matching session, not the page.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Filter by session status"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 50
            },
            "description": "Maximum number of sessions to return"
          }
        ],
        "responses": {
          "200": {
            "description": "Recent sessions",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "sessions": {
                      "type": "array",
                      "items": {
                        "allOf": [
                          {
                            "$ref": "#/components/schemas/KycSession"
                          },
                          {
                            "type": "object",
                            "properties": {
                              "customer_name": {
                                "type": ["string", "null"]
                              },
                              "customer_type": {
                                "type": ["string", "null"]
                              }
                            }
                          }
                        ]
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/kyc-config/sessions/{customerId}": {
      "get": {
        "operationId": "listKycSessions",
        "tags": ["KycConfig"],
        "summary": "List all KYC verification sessions for a customer",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Session list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "sessions": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/KycSession"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/kyc-config/callback": {
      "post": {
        "operationId": "kycCallback",
        "tags": ["KycConfig"],
        "summary": "KYC provider callback webhook",
        "description": "Receives session status changes from the KYC provider. Verifies the\ncallbackApiKey, updates the session record, and triggers auto-approve\nlogic if the session result is APPROVED and config threshold is met.\nOnly a word that names a result is stored (approved, rejected, expired,\ncancelled, more documents required, manual check); a running session or\nan unknown word is acknowledged with `{\"acknowledged\":true,\"stored\":false,\n\"reason\":\"no_final_result\"}`. A session with a final result (approved,\nrejected, expired, cancelled) keeps it: a different result is answered\n200 `{\"acknowledged\":true,\"stored\":false,\"reason\":\"kyc_session_decided\"}`.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["type", "callbackApiKey", "sessionId"],
                "properties": {
                  "type": {
                    "type": "string",
                    "description": "Callback type (e.g. session-change)"
                  },
                  "callbackApiKey": {
                    "type": "string"
                  },
                  "sessionId": {
                    "type": "string"
                  },
                  "result": {
                    "type": "string",
                    "enum": ["APPROVED", "REJECTED"]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Callback processed"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/v1/cdd/addresses": {
      "post": {
        "operationId": "addCddAddress",
        "tags": ["CDD"],
        "summary": "Add a customer address (triggers CDD check)",
        "description": "Registers a new address for a customer. If a matching CDD policy exists,\nan address verification check is automatically created.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "customer_id",
                  "tenant_id",
                  "address_data",
                  "country"
                ],
                "properties": {
                  "customer_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "tenant_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "address_data": {
                    "type": "string",
                    "description": "JSON-encoded address fields"
                  },
                  "country": {
                    "type": "string",
                    "description": "ISO 3166-1 alpha-2"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Address created, CDD check triggered if policy matches"
          }
        }
      }
    },
    "/api/v1/cdd/addresses/{customerId}": {
      "get": {
        "operationId": "listCddAddresses",
        "tags": ["CDD"],
        "summary": "List all addresses for a customer",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Address history"
          }
        }
      }
    },
    "/api/v1/cdd/addresses/current/{customerId}": {
      "get": {
        "operationId": "getCurrentCddAddress",
        "tags": ["CDD"],
        "summary": "Get current (active) address for a customer",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current address"
          },
          "404": {
            "description": "No current address found"
          }
        }
      }
    },
    "/api/v1/cdd/addresses/{addressId}": {
      "put": {
        "operationId": "updateCddAddress",
        "tags": ["CDD"],
        "summary": "Update a customer address record",
        "description": "Updates the address fields for an existing CDD address record.\nResets verification status to `pending` since the address data\nhas changed and needs re-verification.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "addressId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "address_line1": {
                    "type": "string"
                  },
                  "address_line2": {
                    "type": "string"
                  },
                  "city": {
                    "type": "string"
                  },
                  "postal_code": {
                    "type": "string"
                  },
                  "country": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Address updated"
          },
          "404": {
            "description": "Address not found"
          }
        }
      }
    },
    "/api/v1/cdd/addresses/{addressId}/verify": {
      "put": {
        "operationId": "updateCddAddressVerification",
        "tags": ["CDD"],
        "summary": "Update address verification status",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "addressId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["verification_status"],
                "properties": {
                  "verification_status": {
                    "type": "string",
                    "enum": ["verified", "failed", "pending"]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Verification updated"
          },
          "404": {
            "description": "Address not found or not current"
          }
        }
      }
    },
    "/api/v1/cdd/risk/{customerId}": {
      "get": {
        "operationId": "getCddRiskLevel",
        "tags": ["CDD"],
        "summary": "Get customer CDD risk level",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Risk level",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "customer_id": {
                      "type": "string"
                    },
                    "risk_level": {
                      "type": "string",
                      "enum": ["low", "medium", "high", "prohibited"]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Customer not found"
          }
        }
      },
      "put": {
        "operationId": "updateCddRiskLevel",
        "tags": ["CDD"],
        "summary": "Update customer CDD risk level",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["risk_level"],
                "properties": {
                  "risk_level": {
                    "type": "string",
                    "enum": ["low", "medium", "high", "prohibited"]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Risk level updated"
          },
          "404": {
            "description": "Customer not found"
          },
          "409": {
            "description": "`{\"error\":\"pep_requires_high_risk\"}`: the customer has a confirmed\nPEP match; its risk level is not lowered below high (migration\n294).\n"
          }
        }
      }
    },
    "/api/v1/cdd/policies": {
      "get": {
        "operationId": "listCddPolicies",
        "tags": ["CDD"],
        "summary": "List CDD policies",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Policy list"
          }
        }
      },
      "post": {
        "operationId": "createCddPolicy",
        "tags": ["CDD"],
        "summary": "Create a CDD policy",
        "description": "Defines which check applies to which risk level, customer type and\njurisdiction, how deep it verifies and its SLA. Created in draft\nstatus. A policy for a key (jurisdiction, check type, risk level,\ncustomer type) that already has one is its next version. A\njurisdiction without a profile is refused with 422.\n\nThe session's staff id is stored as `created_by_staff_id` (0.30.0,\nmigration 247; null for a service key acting for nobody): the\nfour-eyes check on activation compares it. `created_by` stays the\nemail shown in the history: for a staff session the session\nofficer's (DEC-0043; a body `created_by` is ignored, and a session\nwhose person is no active staff member is 403 `person_required`),\nfor a service call the body's.\n\nPolicies are the platform's baseline (W9; a jurisdiction's policy\nbinds every bank of it): only a super_admin (platform scope) writes\nthem, a bank MLRO is 403 `platform_baseline`; activation is by a\nsecond super_admin. A policy keeps the EDD triggers its floor\nrequires (migration 279, `cdd_policy_missing_triggers`):\n`risk_change` on a high-risk policy, `periodic_review` on a\nrisk_reclassification policy of a jurisdiction with periodic review;\n422 `edd_trigger_required` with `missing`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["check_type", "risk_level", "verification_depth"],
                "properties": {
                  "jurisdiction_code": {
                    "type": "string",
                    "description": "ISO country with a jurisdiction profile; omitted for a global policy"
                  },
                  "check_type": {
                    "type": "string",
                    "enum": [
                      "address_verification",
                      "pep_screening",
                      "sanctions_screening",
                      "document_validity",
                      "source_of_funds",
                      "risk_reclassification"
                    ]
                  },
                  "risk_level": {
                    "type": "string",
                    "enum": ["low", "medium", "high"]
                  },
                  "customer_type": {
                    "type": "string",
                    "enum": ["individual", "business", "any"],
                    "default": "any"
                  },
                  "verification_depth": {
                    "type": "string",
                    "enum": [
                      "self_declaration",
                      "single_source",
                      "dual_source",
                      "authoritative"
                    ]
                  },
                  "sla_hours": {
                    "type": "string",
                    "description": "Hours, as a quoted integer; default 72"
                  },
                  "trigger_rules": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "provider_priority": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "notes": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Policy created in draft status, with its version"
          },
          "400": {
            "description": "A required field is missing"
          },
          "403": {
            "description": "`platform_baseline`: only the platform scope writes CDD policies"
          },
          "422": {
            "description": "No jurisdiction profile for this country, or `edd_trigger_required` with `missing`"
          }
        }
      }
    },
    "/api/v1/cdd/policies/{policyId}": {
      "get": {
        "operationId": "getCddPolicy",
        "tags": ["CDD"],
        "summary": "Get a CDD policy by ID",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "policyId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Policy details"
          },
          "404": {
            "description": "Policy not found"
          }
        }
      }
    },
    "/api/v1/cdd/policies/{policyId}/activate": {
      "post": {
        "operationId": "activateCddPolicy",
        "tags": ["CDD"],
        "summary": "Activate a draft CDD policy",
        "description": "Four-eyes (DEC-0035 amendment of 2026-10-05, migration 247; 0.30.0):\nthe activator is the session's person, compared with the draft's\ncreator by staff id (never by email), and is somebody else. For a\npolicy of a jurisdiction: an active `mlro` of the session bank's\ncell, the bank having that jurisdiction. For a global policy (no\njurisdiction): a `super_admin` in the platform scope. A draft with\nno recorded creator id (`created_by_staff_id` null: created before\n247 or by a service key) is activated by any such officer except\nthe one its `created_by` email names (lower case; a match only\nrefuses). `approved_by` and `approved_by_staff_id` are the\nactivator's email (read from the staff record by id) and id; a body\nis no longer needed and its `approved_by` is ignored. Audit\n`cdd.policy.activated` (1900, actor `staff:<id>`) names the creator\nand the activator (ids and emails), one row per bank tenant the\npolicy binds that the caller's scope reaches (a cell MLRO: its own\nbank). A `four_eyes_required` refusal is audited as\n`cdd.policy.activation_refused` (1901, severity warn).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "policyId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "approved_by": {
                    "type": "string",
                    "deprecated": true,
                    "description": "Ignored since 0.30.0; the activator is the session's person"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Policy activated. The active policy of the same key is archived in\nthe same statement; its id is in retired_ids.\n"
          },
          "403": {
            "description": "`{\"error\":\"person_required\"}`: no person (a service key acting for\nnobody, or no active staff record for the session's id).\n`{\"error\":\"four_eyes_required\"}`: the draft's creator (by id, or\nby the `created_by` email when no creator id is recorded), or\nnot an active `mlro` of a cell bank of the policy's jurisdiction\n(the platform scope for a global policy). A role that may not change\nthe policy at all: `{\"error\":\"Only a super admin may change a\nglobal policy or another jurisdiction's policy\"}`.\n"
          },
          "404": {
            "description": "Policy not found or not in draft status"
          },
          "409": {
            "description": "A newer version of this policy is active"
          }
        }
      }
    },
    "/api/v1/cdd/policies/{policyId}/archive": {
      "post": {
        "operationId": "archiveCddPolicy",
        "tags": ["CDD"],
        "summary": "Archive a CDD policy (four-eyes for an active one)",
        "description": "A draft binds nobody and is archived at once. An active policy leaves\nforce (W9, migration 279): the first call, with a `reason` (10 to\n1000 characters), records the request (202); a second eligible\nperson's call archives it (200); the requester's own call is 403\n`four_eyes_required`. The archiver is the session's person; a body\n`archived_by` is ignored. Policies are the platform's baseline: only\na super_admin (platform scope) archives (403 `platform_baseline`).\nAudit `cdd.policy.archive_requested` / `cdd.policy.archived` (700).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "policyId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 10,
                    "maxLength": 1000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Policy archived"
          },
          "202": {
            "description": "Archive requested; a second person confirms"
          },
          "400": {
            "description": "`reason_required`"
          },
          "403": {
            "description": "`platform_baseline`, `person_required` or `four_eyes_required`"
          },
          "404": {
            "description": "Policy not found or already archived"
          }
        }
      }
    },
    "/api/v1/cdd/policies/{policyId}/archive/cancel": {
      "post": {
        "operationId": "cancelCddPolicyArchive",
        "tags": ["CDD"],
        "summary": "Drop a pending archive request",
        "description": "The requester withdraws it, or another eligible officer turns it down. Audit `cdd.policy.archive_cancelled` (700).",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "policyId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Request dropped; the policy stays active"
          },
          "403": {
            "description": "`platform_baseline`, `person_required` or `four_eyes_required`"
          },
          "404": {
            "description": "No active policy with this id"
          },
          "409": {
            "description": "`not_pending`"
          }
        }
      }
    },
    "/api/v1/cdd/bank-rules": {
      "get": {
        "operationId": "getCddBankRules",
        "tags": ["CDD"],
        "summary": "The bank's CDD rules on the platform's baseline",
        "description": "One bank's book (the session's bank; the platform scope names it in\n`X-Tenant-ID` or `tenant_id`, else 400 `tenant_required`):\n`baseline`, the platform's active policies that apply to the bank\n(its jurisdiction's and the global ones it does not override; set by\nthe platform, read-only here); `rules`, the bank's stricter rules\n(draft, pending and active versions, and per key the newest decided\none) with `can` (what the caller may do) and `problems` (what would\nloosen the baseline today); `effective`, the policy each check type,\nrisk level and customer type runs under now: the baseline merged\nwith the bank's active rules, stricter wins (the deepest\nverification, the shortest SLA, every trigger and provider), with\n`source` per value (`baseline`, `bank`, `both`; `incomplete` with\n`missing` when a key only the bank covers has no depth or SLA); `problems`,\nwhat needs the bank's attention after the platform changed or archived a\nbaseline (kind `rule`: an active rule no longer stricter, with its\n`violations`; kind `incomplete`: an effective policy without depth or SLA,\nwith `missing`); `history`, the newest 200 events. Readers: a cell `mlro` or `auditor`, the platform\nscope, a service key.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The bank, for the platform scope (a cell session reads its own)"
          }
        ],
        "responses": {
          "200": {
            "description": "{tenant_id, jurisdiction_code, viewer, baseline, rules, effective, history}"
          },
          "400": {
            "description": "`tenant_required`"
          },
          "403": {
            "description": "`forbidden`: not a reader"
          }
        }
      },
      "post": {
        "operationId": "createCddBankRule",
        "tags": ["CDD"],
        "summary": "Write a stricter CDD rule (a draft)",
        "description": "A maker writes a draft rule for one check type, risk level and\ncustomer type: an active `mlro` of the bank's cell, or a\n`super_admin` in the platform scope acting for the bank, who gives a\n`reason` (10 to 1000 characters; 400 `acting_reason_required`;\nrecorded as `acting_reason` and audited with `acting_for_tenant`).\nTighten only (migration 289, `finance_cdd_bank_rule_problems`):\n`verification_depth` at least the baseline's, `sla_hours` at most\nthe baseline's, `extra_triggers` and `extra_providers` added to the\nbaseline's; a rule 'any' is judged per customer type, against the\nbaseline of individuals and of businesses. Where a customer type has\nno baseline (an extra check type or risk level), the rule names its\ndepth and SLA and keeps the floor's EDD triggers. Anything else is 422 `tighten_only_violation` with\n`violations` ({field, reason, baseline?, customer_type?}); the\ndatabase refuses the same for every writer. A key with a draft or a\npending version is 409 `change_pending`. The draft is the next\nversion of the key. Audit `cdd.bank_rule.created` (700).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["check_type", "risk_level"],
                "properties": {
                  "check_type": {
                    "type": "string",
                    "enum": [
                      "address_verification",
                      "pep_screening",
                      "sanctions_screening",
                      "document_validity",
                      "source_of_funds",
                      "risk_reclassification"
                    ]
                  },
                  "risk_level": {
                    "type": "string",
                    "enum": ["low", "medium", "high"]
                  },
                  "customer_type": {
                    "type": "string",
                    "enum": ["individual", "business", "any"],
                    "default": "any"
                  },
                  "verification_depth": {
                    "type": ["string", "null"],
                    "enum": [
                      "self_declaration",
                      "single_source",
                      "dual_source",
                      "authoritative",
                      null
                    ],
                    "description": "Null keeps the baseline's"
                  },
                  "sla_hours": {
                    "type": ["integer", "null"],
                    "minimum": 1,
                    "maximum": 720,
                    "description": "Null keeps the baseline's"
                  },
                  "extra_triggers": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "extra_providers": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "maxLength": 50
                    }
                  },
                  "notes": {
                    "type": "string",
                    "maxLength": 2000
                  },
                  "reason": {
                    "type": "string",
                    "description": "Required for a super_admin acting for the bank (10 to 1000 characters)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The draft rule"
          },
          "400": {
            "description": "`acting_reason_required` or `tenant_required`"
          },
          "403": {
            "description": "`mlro_required`, `person_required` or `session_required`"
          },
          "409": {
            "description": "`change_pending`"
          },
          "422": {
            "description": "`tighten_only_violation` with `violations`"
          }
        }
      }
    },
    "/api/v1/cdd/bank-rules/{ruleId}": {
      "put": {
        "operationId": "editCddBankRule",
        "tags": ["CDD"],
        "summary": "Edit a bank rule (a new draft version)",
        "description": "A new draft version of the rule's key (check type, risk level and\ncustomer type come from the rule; the body's are ignored), with the\nsame checks as a create. Editing one's own draft replaces it (the\nold draft is withdrawn); another maker's draft is 403\n`creator_only`; a pending or superseded version is 409\n`wrong_status`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "ruleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "verification_depth": {
                    "type": ["string", "null"]
                  },
                  "sla_hours": {
                    "type": ["integer", "null"],
                    "minimum": 1,
                    "maximum": 720
                  },
                  "extra_triggers": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "extra_providers": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "maxLength": 50
                    }
                  },
                  "notes": {
                    "type": "string",
                    "maxLength": 2000
                  },
                  "reason": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The new draft version"
          },
          "403": {
            "description": "`creator_only`, `mlro_required` or `person_required`"
          },
          "404": {
            "description": "No such rule of this bank"
          },
          "409": {
            "description": "`change_pending` or `wrong_status`"
          },
          "422": {
            "description": "`tighten_only_violation` with `violations`"
          }
        }
      }
    },
    "/api/v1/cdd/bank-rules/{ruleId}/history": {
      "get": {
        "operationId": "getCddBankRuleHistory",
        "tags": ["CDD"],
        "summary": "Every version of a bank rule's key and its events",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "ruleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{versions, events}: who made, submitted, approved, rejected, withdrew or deactivated which version, when and why"
          },
          "404": {
            "description": "No such rule of this bank"
          }
        }
      }
    },
    "/api/v1/cdd/bank-rules/{ruleId}/submit": {
      "post": {
        "operationId": "submitCddBankRule",
        "tags": ["CDD"],
        "summary": "Submit a draft rule for approval",
        "description": "The draft's maker asks a second officer (pending). Audit `cdd.bank_rule.submitted`.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "ruleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The rule, pending"
          },
          "403": {
            "description": "`creator_only`"
          },
          "409": {
            "description": "`wrong_status`: not a draft"
          }
        }
      }
    },
    "/api/v1/cdd/bank-rules/{ruleId}/approve": {
      "post": {
        "operationId": "approveCddBankRule",
        "tags": ["CDD"],
        "summary": "Approve a pending rule (a second MLRO of the bank)",
        "description": "Four-eyes: an active `mlro` of the bank's cell other than the maker\nand the submitter activates the rule; the active version of the key\nis superseded. A `super_admin` may make a rule for the bank but\nnever checks one: 403 `checker_must_be_bank_officer`; the maker: 403\n`four_eyes_required` (the database refuses both, SQLSTATE CD003 and\nCD002). A rule that has become looser than the baseline since it was\nwritten is 422 `tighten_only_violation`. Audit\n`cdd.bank_rule.approved` names both people.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "ruleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string",
                    "maxLength": 1000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The rule, active"
          },
          "403": {
            "description": "`checker_must_be_bank_officer` or `four_eyes_required`"
          },
          "409": {
            "description": "`wrong_status`: not pending"
          },
          "422": {
            "description": "`tighten_only_violation` with `violations`"
          }
        }
      }
    },
    "/api/v1/cdd/bank-rules/{ruleId}/reject": {
      "post": {
        "operationId": "rejectCddBankRule",
        "tags": ["CDD"],
        "summary": "Reject a pending rule, or withdraw one's own",
        "description": "A second MLRO of the bank rejects a pending rule with a `reason` (10\nto 1000 characters); the maker's own call withdraws a draft or a\npending rule (reason optional). A `super_admin` rejects nothing it\ndid not make: 403 `checker_must_be_bank_officer`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "ruleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string",
                    "maxLength": 1000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The rule, rejected or withdrawn"
          },
          "400": {
            "description": "`reason_required`"
          },
          "403": {
            "description": "`checker_must_be_bank_officer` or `four_eyes_required`"
          },
          "409": {
            "description": "`wrong_status`"
          }
        }
      }
    },
    "/api/v1/cdd/bank-rules/{ruleId}/deactivate": {
      "post": {
        "operationId": "deactivateCddBankRule",
        "tags": ["CDD"],
        "summary": "Deactivate an active rule (four-eyes)",
        "description": "The first call, by a maker with a `reason` (10 to 1000 characters),\nrecords the request (202); a second MLRO of the bank confirms (200)\nand the bank's customers return to the baseline for that key. The\nrequester's own confirmation is 403 `four_eyes_required`, a\n`super_admin`'s 403 `checker_must_be_bank_officer`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "ruleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 10,
                    "maxLength": 1000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The rule, deactivated"
          },
          "202": {
            "description": "Deactivation requested; a second MLRO of the bank confirms"
          },
          "400": {
            "description": "`reason_required`"
          },
          "403": {
            "description": "`checker_must_be_bank_officer` or `four_eyes_required`"
          },
          "409": {
            "description": "`wrong_status`: not active"
          }
        }
      }
    },
    "/api/v1/cdd/bank-rules/{ruleId}/deactivate/cancel": {
      "post": {
        "operationId": "cancelCddBankRuleDeactivation",
        "tags": ["CDD"],
        "summary": "Drop a pending deactivation",
        "description": "The requester withdraws it, or another MLRO of the bank turns it down.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "ruleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The rule, still active"
          },
          "403": {
            "description": "`checker_must_be_bank_officer`"
          },
          "409": {
            "description": "`wrong_status`: no deactivation pending"
          }
        }
      }
    },
    "/api/v1/cdd/checks": {
      "post": {
        "operationId": "createCddCheck",
        "tags": ["CDD"],
        "summary": "Create a CDD check",
        "description": "The check is raised under the customer's effective policy (migration 289: the\nbaseline merged with the bank's stricter rules), chosen by the customer's own\nrisk level and type; `risk_level_at_trigger` is recorded as given, else the\ncustomer's. The row carries `bank_rule_id`, `sla_hours` and `effective_policy`.\nA customer not of the given bank: 404.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "customer_id",
                  "tenant_id",
                  "check_type",
                  "trigger_type"
                ],
                "properties": {
                  "customer_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "tenant_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "check_type": {
                    "type": "string"
                  },
                  "trigger_type": {
                    "type": "string",
                    "description": "e.g., address_changed, onboarding, periodic"
                  },
                  "risk_level_at_trigger": {
                    "type": "string"
                  },
                  "policy_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "policy_version": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Check created"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          }
        }
      }
    },
    "/api/v1/cdd/checks/manual": {
      "post": {
        "operationId": "staffManualCddCheck",
        "tags": ["CDD"],
        "summary": "Run a manual CDD check for a customer of the bank",
        "description": "finance-api runs Restate CddPolicyEngine `manualCheck` for a customer\nof the session's bank, with the session's officer as requester (final\nreview M2 of feature/super-admin-assist; Core no longer calls\nRestate). The bank's `mlro`, or the platform `super_admin` on the\nbank's behalf with `X-Tenant-ID` and a reason (see \"Platform\nassist\"). One run per `Idempotency-Key`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/ChangeReason"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["customer_id", "justification"],
                "properties": {
                  "customer_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "check_type": {
                    "type": "string",
                    "enum": ["address_verification"]
                  },
                  "justification": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1000
                  },
                  "tenant_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "must be the bank of the request"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The engine's answer",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "result": {
                      "type": "object",
                      "additionalProperties": true
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`customer_required`, `invalid_id`, `invalid_check_type`, `justification_required`, `idempotency_key_required`, `reason_required`, `tenant_required`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "404": {
            "description": "`customer_not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "`cdd_check_failed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/cdd/checks/{checkId}": {
      "get": {
        "operationId": "getCddCheck",
        "tags": ["CDD"],
        "summary": "Get a CDD check by ID",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "checkId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Check details"
          },
          "404": {
            "description": "Check not found"
          }
        }
      }
    },
    "/api/v1/cdd/checks/open/{tenantId}": {
      "get": {
        "operationId": "listOpenCddChecks",
        "tags": ["CDD"],
        "summary": "List open CDD checks for a tenant",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tenantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Open check list"
          }
        }
      }
    },
    "/api/v1/cdd/checks/customer/{customerId}": {
      "get": {
        "operationId": "listCddChecksByCustomer",
        "tags": ["CDD"],
        "summary": "List CDD checks for a customer",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Check list for customer"
          }
        }
      }
    },
    "/api/v1/cdd/checks/{checkId}/start": {
      "post": {
        "operationId": "startCddCheck",
        "tags": ["CDD"],
        "summary": "Start a CDD check (transition to in_progress)",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "checkId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["provider"],
                "properties": {
                  "provider": {
                    "type": "string",
                    "description": "Verification provider name"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Check started"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "404": {
            "description": "Check not found or not pending"
          }
        }
      }
    },
    "/api/v1/cdd/checks/{checkId}/complete": {
      "post": {
        "operationId": "completeCddCheck",
        "tags": ["CDD"],
        "summary": "Complete a CDD check with result",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "checkId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["result"],
                "properties": {
                  "result": {
                    "type": "string",
                    "enum": ["pass", "fail", "review_required"]
                  },
                  "result_details": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Check completed"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "404": {
            "description": "Check not found or already completed"
          }
        }
      }
    },
    "/api/v1/cdd/checks/{checkId}/resolve": {
      "post": {
        "operationId": "resolveCddCheck",
        "tags": ["CDD"],
        "summary": "Compliance officer resolution of a completed check",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "checkId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["resolved_by"],
                "properties": {
                  "resolved_by": {
                    "type": "string"
                  },
                  "resolution_notes": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Check resolved"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "404": {
            "description": "Check not found or not completed"
          }
        }
      }
    },
    "/api/v1/cdd/checks/{checkId}/escalate": {
      "post": {
        "operationId": "escalateCddCheck",
        "tags": ["CDD"],
        "summary": "Escalate a CDD check",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "checkId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Check escalated"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "404": {
            "description": "Check not found or cannot be escalated"
          }
        }
      }
    },
    "/api/v1/cdd/checks/{checkId}/cancel": {
      "post": {
        "operationId": "cancelCddCheck",
        "tags": ["CDD"],
        "summary": "Cancel a pending CDD check",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "checkId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Check cancelled"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "404": {
            "description": "Check not found or cannot be cancelled"
          }
        }
      }
    },
    "/api/v1/screening/config": {
      "get": {
        "operationId": "getScreeningConfig",
        "tags": ["Screening"],
        "summary": "Get tenant screening configuration",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "X-Tenant-ID",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Screening config with the bank's floor",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScreeningConfig"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateScreeningConfig",
        "tags": ["Screening"],
        "summary": "Update tenant screening configuration",
        "description": "A partial update (a field left out keeps its value) with a `reason`\n(10 to 1000 characters) by an MLRO of the bank in a staff session (a\nservice key acting for nobody is 403 `person_required`; the platform\nscope reads only). Every value stays inside the bank's floor\n(migration 279, `compliance_floor_of`): scores and the re-screen\nwindow at most the ceiling, the required sources (SANCTIONS-LISTS)\nalways screened; outside it is 422 `screening_floor` with `field`\nand `limit`. Each change is a history row (before, after, direction,\nreason, the session person) and an audit row\n`screening.config.updated` (1005) carrying it.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "X-Tenant-ID",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ScreeningConfigUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Config updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScreeningConfig"
                }
              }
            }
          },
          "400": {
            "description": "`reason_required` or `invalid_field` with `field`"
          },
          "403": {
            "description": "`person_required`, or not an MLRO of the bank; `forbidden_role` from the staff route gate (DEC-0043)"
          },
          "422": {
            "description": "`screening_floor` with `field` and `limit`"
          }
        }
      }
    },
    "/api/v1/screening/config/history": {
      "get": {
        "operationId": "getScreeningConfigHistory",
        "tags": ["Screening"],
        "summary": "Change history of the screening thresholds",
        "description": "Newest first, at most 100 rows (finance_screening_config_history, append-only).",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "X-Tenant-ID",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "History",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScreeningConfigHistory"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/screening/search": {
      "post": {
        "operationId": "screenManual",
        "tags": ["Screening"],
        "summary": "Manual sanctions screening (MLRO ad-hoc)",
        "description": "A screening write: the roles that decide screening results (a cell\nMLRO, the platform scope, a service key); every other staff role is\n403. The result is stored. A customer is set to `clear` only when no\nscreening result of the customer is still open (pending or\npotential_match); otherwise the customer stays `pending_review`, so a\nre-screen with no match does not clear a result that awaits its\ndecision, also one a compliance case links (DEC-0035). `blocked` is\nnever left.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "X-Tenant-ID",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["name", "subject_id"],
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 200
                  },
                  "subject_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "subject_type": {
                    "type": "string",
                    "enum": ["customer", "beneficiary", "entity"],
                    "default": "customer"
                  },
                  "date_of_birth": {
                    "type": "string",
                    "format": "date"
                  },
                  "nationality": {
                    "type": "string",
                    "maxLength": 2
                  },
                  "country": {
                    "type": "string",
                    "maxLength": 2
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Screening result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScreeningOutcome"
                }
              }
            }
          },
          "403": {
            "description": "The role may not change screening (only an MLRO, the platform scope or a service key)"
          }
        }
      }
    },
    "/api/v1/screening/search/existing": {
      "get": {
        "operationId": "checkExistingScreening",
        "tags": ["Screening"],
        "summary": "Pre-search check for prior screening results by subject name",
        "description": "Returns up to 10 most recent screening results matching the given name (case-insensitive). Used to avoid duplicate sanctions.io API calls and surface prior screening history for audit purposes.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "X-Tenant-ID",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "name",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 2
            },
            "description": "Subject name to search for (case-insensitive match)"
          }
        ],
        "responses": {
          "200": {
            "description": "List of existing screening results (may be empty)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScreeningResultList"
                }
              }
            }
          },
          "400": {
            "description": "Missing or invalid name parameter"
          }
        }
      }
    },
    "/api/v1/screening/search/batch": {
      "post": {
        "operationId": "screenBatch",
        "tags": ["Screening"],
        "summary": "Batch screening for corporate entity + UBOs",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "X-Tenant-ID",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["subjects"],
                "properties": {
                  "subjects": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/BatchSubject"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Batch screening results"
          }
        }
      }
    },
    "/api/v1/screening/search/media": {
      "post": {
        "operationId": "screenAdverseMedia",
        "tags": ["Screening"],
        "summary": "Adverse media screening",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "X-Tenant-ID",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["name", "subject_id"],
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "subject_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "keywords": {
                    "type": "string"
                  },
                  "country": {
                    "type": "string",
                    "maxLength": 2
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Adverse media results"
          }
        }
      }
    },
    "/api/v1/screening/results": {
      "get": {
        "operationId": "listScreeningResults",
        "tags": ["Screening"],
        "summary": "List screening results with filters",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "no_match",
                "auto_cleared",
                "potential_match",
                "confirmed_match",
                "false_positive"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Results list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "results": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ScreeningResult"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/screening/results/{resultId}": {
      "get": {
        "operationId": "getScreeningResult",
        "tags": ["Screening"],
        "summary": "Get screening result detail",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "resultId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Result detail",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScreeningResult"
                }
              }
            }
          },
          "404": {
            "description": "Result not found"
          }
        }
      }
    },
    "/api/v1/screening/results/{resultId}/resolve": {
      "patch": {
        "operationId": "resolveScreeningResult",
        "tags": ["Screening"],
        "summary": "Resolve a screening match (MLRO decision)",
        "description": "MLRO resolves a potential match as false_positive or confirmed_match.\nfalse_positive clears the customer for wallet provisioning.\nconfirmed_match blocks the account and initiates SAR process.\nResolution notes are required for the record.\n\nA sanctions (non-PEP) match on a customer that an open compliance case\ndecides is refused with 409 `screening_decided_in_case`: the officer\ndecides it on the case (disposition `freeze` confirms, `false_positive`\nclears). PEP results are resolved here (ES-case-decides-screening).\n\nA confirmed PEP match on a customer opens its enhanced due diligence\nreview (migration 294) in the same transaction: the customer's risk\nlevel becomes high, ongoing screening is on, and `edd_review_id`\nnames the review. The screening stays `pending_review` until a second\nofficer approves the review (`/api/v1/edd-reviews`).\n\nFour-eyes (DEC-0035): `false_positive` on a sanctions result that any\ncase links, also a closed one, is 409 `decide_in_case`; `case_id` is\nthe newest linking case (an open one first, else the newest closed).\nIt is cleared on a case (false positive approved by a second MLRO;\nfor a case closed undecided, a new case on the result). A result no\ncase links is resolved here as before.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "resultId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["resolution", "notes"],
                "properties": {
                  "resolution": {
                    "type": "string",
                    "enum": ["false_positive", "confirmed_match"]
                  },
                  "notes": {
                    "type": "string",
                    "minLength": 3
                  },
                  "resolved_by": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result resolved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["resolved", "subject_id", "frozen"],
                  "properties": {
                    "resolved": {
                      "type": "boolean"
                    },
                    "subject_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "frozen": {
                      "type": "boolean"
                    },
                    "case_id": {
                      "type": "string",
                      "format": "uuid",
                      "description": "The compliance case that froze the customer (a confirmed sanctions match)."
                    },
                    "edd_review_id": {
                      "type": "string",
                      "format": "uuid",
                      "description": "The EDD review a confirmed PEP match opened."
                    }
                  }
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "404": {
            "description": "Result not found"
          },
          "409": {
            "description": "`screening_decided_in_case`: an open compliance case decides this\nresult. `decide_in_case`: a false positive on a sanctions result\nthat a case links (open or closed) is cleared on a case. `case_id`\nnames the case (absent when none is found: filter by subject).\n",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["error"],
                  "properties": {
                    "error": {
                      "type": "string",
                      "enum": ["screening_decided_in_case", "decide_in_case"]
                    },
                    "case_id": {
                      "type": "string",
                      "format": "uuid",
                      "description": "The newest case linking the result (open first, else the newest closed)."
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/screening/results/{resultId}/case": {
      "post": {
        "operationId": "openScreeningCase",
        "tags": ["Screening"],
        "summary": "Open the case that decides a screening result",
        "description": "ES-case-decides-screening. Locks the result row, returns the open\ncompliance case that already decides it (never reassigned), or opens\na `screening_alert` case on `screening:<resultId>` for the result's\ncustomer, assigned to the officer of the session when that officer\nmay hold cases. At most one open case decides a result. MLRO or the\nplatform scope only; the officer is the session email.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "resultId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "actor": {
                    "type": "string",
                    "description": "Service callers only; staff calls use the session email."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The open case that already decides the result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScreeningCaseOpened"
                }
              }
            }
          },
          "201": {
            "description": "A case was opened on the result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScreeningCaseOpened"
                }
              }
            }
          },
          "403": {
            "description": "`forbidden_role` (DEC-0043): not the bank's `mlro`, the platform scope included; no officer identity (`officer_required`)"
          },
          "404": {
            "description": "Result not found"
          },
          "409": {
            "description": "The result was decided on the desk and no case names it (`screening_result_decided`). A result a case decided returns that case (200, `created:false`); a decided result never gets a new case."
          },
          "422": {
            "description": "The result is not about a customer (`screening_case_customer_only`)"
          }
        }
      }
    },
    "/api/v1/compliance-cases": {
      "get": {
        "operationId": "listComplianceCases",
        "tags": ["Screening"],
        "summary": "List the tenant's compliance cases",
        "description": "Newest first. `status=active` lists every open, investigating and\npending_filing case (the case board; default and maximum limit 500),\nso older open cases no longer drop out of a page of 50. Every row\ncarries `freeze_live` and `pending_approval` (the request for a\nsecond officer that waits on the case, or null; DEC-0035), and its\nclock: `due_at`, `overdue`, `overdue_at`; `retention_until` once\nclosed and `previous_case_id` when it follows a closed case.\n\nThe tenant is required: the `X-Tenant-ID` header or the `tenant_id`\nquery parameter (400 without either).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "X-Tenant-ID",
            "in": "header",
            "description": "The case's tenant; required unless `tenant_id` is given.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "tenant_id",
            "in": "query",
            "description": "The case's tenant; required unless `X-Tenant-ID` is given.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "open",
                "investigating",
                "pending_filing",
                "closed",
                "active"
              ]
            }
          },
          {
            "name": "assignee",
            "in": "query",
            "description": "`none` for unassigned cases, or an officer's email.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Default 50 (500 with `status=active`); at most 500.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The cases",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["cases"],
                  "properties": {
                    "cases": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "description": "The case row with `freeze_live`, `pending_approval` and its clock.",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "open",
                              "investigating",
                              "pending_filing",
                              "closed"
                            ]
                          },
                          "freeze_live": {
                            "type": "boolean"
                          },
                          "due_at": {
                            "type": "string",
                            "format": "date-time",
                            "description": "When the case is due for a decision (opened + the jurisdiction's `case_review_days`, default 30 days)."
                          },
                          "overdue": {
                            "type": "boolean",
                            "description": "Open and past `due_at`, now."
                          },
                          "overdue_at": {
                            "type": ["string", "null"],
                            "format": "date-time",
                            "description": "When the overdue sweep first flagged the case."
                          },
                          "retention_until": {
                            "type": ["string", "null"],
                            "format": "date-time",
                            "description": "Set at close; closed_at + the jurisdiction's AML record-keeping years (default 5)."
                          },
                          "previous_case_id": {
                            "type": ["string", "null"],
                            "format": "uuid",
                            "description": "The closed case this case follows."
                          },
                          "pending_approval": {
                            "oneOf": [
                              {
                                "$ref": "#/components/schemas/CaseApprovalPending"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing tenant or invalid query"
          }
        }
      }
    },
    "/api/v1/compliance-cases/decision-context": {
      "get": {
        "operationId": "getComplianceDecisionContext",
        "tags": ["Screening"],
        "summary": "Everything the decision view of an alert or a case shows",
        "description": "Read-only. What Core-Bank's decision view puts on one page for an\nalert or a case, as data (Core writes the words): the customer\n(type, country, date of birth or registration, customer since, KYC\nand its dates, risk level and recorded risk factors, screening\nstatus and the last screen, the declared monthly amount and\ncountries), the customer's accounts, beneficial owners, the payment\nthat fired the alert, the payments that form the pattern\n(`related.basis`: `inbound_before` for a pass-through rule, the money\nthat arrived on the paying account inside the rule window before\nthe payment; `outbound_window` for count and structuring rules, the\nother payments from that account in the window; `none`), the rule\nand the facts recorded with the hit, list hits of a screening alert\nor result, the identity check sessions, the CDD check, 30- and\n90-day activity per currency with 13 weekly buckets, top\ncounterparties and countries, and the customer's history: other\ncases, earlier alerts with the decision taken, freezes, and reports;\n`open_case` is the open case on the same source (an alert worked in\na case is decided there).\n\nEvery IBAN leaves as its country and last four characters; no card\ndata is read. Every row is read with the bank named (a cell session:\nits own bank, whatever the query says) and under the request's\ntenant context (RLS): another bank's customer reads as nothing.\n`history.sars` is null for a role that does not read reports (the\nauditor). Readers: a cell `mlro` or `auditor`, or the platform\n(`super_admin`, read only); every other role is refused (403\n`forbidden_role`).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "description": "The bank (or `X-Tenant-ID`); a cell session reads its own.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "customer_id",
            "in": "query",
            "description": "The customer behind the alert or case.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "transfer_id",
            "in": "query",
            "description": "The payment that fired the alert.",
            "schema": {
              "type": "string",
              "maxLength": 64,
              "pattern": "^[A-Za-z0-9_-]+$"
            }
          },
          {
            "name": "typology",
            "in": "query",
            "description": "The transaction monitoring typology of a rule hit.",
            "schema": {
              "type": "string",
              "maxLength": 40,
              "pattern": "^[a-z0-9_]+$"
            }
          },
          {
            "name": "source",
            "in": "query",
            "description": "The alert's or case's source; given with `source_id`.",
            "schema": {
              "type": "string",
              "enum": ["sanctions", "transfer", "screening", "kyc", "cdd"]
            }
          },
          {
            "name": "source_id",
            "in": "query",
            "description": "The alert, screening result or check; left out of the history.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "case_id",
            "in": "query",
            "description": "The case on the page; left out of the history.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The decision context",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DecisionContext"
                }
              }
            }
          },
          "400": {
            "description": "Missing bank or a malformed parameter"
          },
          "403": {
            "description": "A role that does not read cases (`forbidden_role`)"
          }
        }
      }
    },
    "/api/v1/compliance-cases/approvals": {
      "get": {
        "operationId": "listComplianceCaseApprovals",
        "tags": ["Screening"],
        "summary": "List requests for a second officer",
        "description": "Four-eyes on case decisions (DEC-0035, migration 246): the tenant's\nrequests, newest first (at most 500). `can` is computed for the\ncaller: approve and reject for another `mlro` of the bank's cell\nwhile the request is pending, withdraw for its requester. A\nsuper_admin never approves or rejects. `approver_available` is false\nwhile the cell has no other active `mlro` (the request waits; there\nis no break-glass).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "X-Tenant-ID",
            "in": "header",
            "description": "The case's tenant; required unless `tenant_id` is given.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "tenant_id",
            "in": "query",
            "description": "The case's tenant; required unless `X-Tenant-ID` is given.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": ["pending", "approved", "rejected", "withdrawn"]
            }
          },
          {
            "name": "case_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The requests",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["approvals"],
                  "properties": {
                    "approvals": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CaseApproval"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing tenant or invalid query"
          }
        }
      }
    },
    "/api/v1/compliance-cases/approvals/{approvalId}/approve": {
      "post": {
        "operationId": "approveComplianceCaseApproval",
        "tags": ["Screening"],
        "summary": "Approve a request as the second officer",
        "description": "Another `mlro` of the case's bank cell approves (compared by staff\nid from the session, never by email). The approval row is locked\nfirst; the effect (lift the freeze, or the false-positive\ndisposition, which also decides the case's screening result) runs\nwith the requester as its actor, then the request is approved, with\nthe `approval_granted` case event and audit 1409 naming both\nofficers. All or nothing. The answer is 409 `approval_stale` and the\nrequest stays pending when the precondition is gone (the case\nclosed, the freeze ended, the result decided elsewhere), when the\ncase's status changed or a freeze, lift, disposition or close was\nwritten after the request, or when the requester is no longer an\nactive staff member.\n\nNeeds a staff session (MFA and current role checked): a service key,\nalso one acting for an operator (`X-Acting-User-ID`), is 403\n`session_required`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "approvalId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "X-Tenant-ID",
            "in": "header",
            "description": "The case's tenant; required unless `tenant_id` is given.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "tenant_id",
            "in": "query",
            "description": "The case's tenant; required unless `X-Tenant-ID` is given.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string",
                    "maxLength": 1000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Approved; the case after the effect",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["approval", "case"],
                  "properties": {
                    "approval": {
                      "$ref": "#/components/schemas/CaseApproval"
                    },
                    "case": {
                      "type": "object",
                      "description": "The case row with `freeze_live` and `pending_approval` (null)."
                    },
                    "thaw": {
                      "type": "string",
                      "enum": ["thawed", "held", "unchanged"],
                      "description": "A lift only: whether the subject was thawed (`held`: another stop stands)."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid id, tenant or reason"
          },
          "403": {
            "description": "`forbidden_role` (DEC-0043): a role other than `mlro`, the\nplatform scope included, before any check. `four_eyes_required`:\nthe caller is the requester, a super_admin, or not an active\n`mlro` of the case's cell. `session_required`: no staff session\n(a service key, also acting for an operator).\n"
          },
          "404": {
            "description": "Request not found (or another tenant's)"
          },
          "409": {
            "description": "`approval_stale`: the precondition is gone; the request stays\npending. `approval_not_pending`: the request was already decided.\n",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["error"],
                  "properties": {
                    "error": {
                      "type": "string",
                      "enum": ["approval_stale", "approval_not_pending"]
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/compliance-cases/approvals/{approvalId}/reject": {
      "post": {
        "operationId": "rejectComplianceCaseApproval",
        "tags": ["Screening"],
        "summary": "Reject a request, or withdraw your own",
        "description": "Another `mlro` of the case's cell rejects with a reason (status\n`rejected`); the requester's reject is a withdrawal (status\n`withdrawn`, reason optional). Nothing on the case changes: a freeze\nstays. Case event `approval_rejected` or `approval_withdrawn`, audit\n1410. Needs a staff session (403 `session_required` for a service\nkey, also one acting for an operator).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "approvalId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "X-Tenant-ID",
            "in": "header",
            "description": "The case's tenant; required unless `tenant_id` is given.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "tenant_id",
            "in": "query",
            "description": "The case's tenant; required unless `X-Tenant-ID` is given.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string",
                    "maxLength": 1000,
                    "description": "Required unless the caller withdraws their own request."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Rejected or withdrawn",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["approval"],
                  "properties": {
                    "approval": {
                      "$ref": "#/components/schemas/CaseApproval"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`reason_required`: a rejection without a reason; or an invalid id, tenant or reason"
          },
          "403": {
            "description": "`forbidden_role` (DEC-0043): a role other than `mlro`, the platform scope included. `four_eyes_required`: neither the requester nor another `mlro` of the cell. `session_required`: no staff session."
          },
          "404": {
            "description": "Request not found (or another tenant's)"
          },
          "409": {
            "description": "`approval_not_pending`: the request was already decided"
          }
        }
      }
    },
    "/api/v1/compliance-cases/workflow": {
      "get": {
        "operationId": "getComplianceCaseWorkflow",
        "tags": ["Screening"],
        "summary": "The case transitions finance-api enforces",
        "description": "The transition table every decision is checked against (DEC-0035,\namendment 2026-10-06), served from the same rows: for each step the\nstatuses it leaves (`from`) and reaches (`to`; null: unchanged,\n`open_to`: what an open case becomes), whether it needs a second\nofficer and on which case types (`*`: all), whether it is never\ngated (a freeze), the case types it applies to (empty: all), the\ndisposition it writes, and the minimum reason length (10 for every\ndecision with a reason). `reason_min` and `approval_reason_max` are\nthe limits of every reason and of an approval's decision reason.\n\nWith a tenant (`tenant_id` or `X-Tenant-ID`) the table is merged\nwith the bank's active workflow overlay (DEC-0035 P1, migration\n280): `four_eyes`, `four_eyes_case_types` and `reason_min` are the\neffective rules (platform plus bank; `reason_min` the minimum for\nevery case type), `platform_*` the platform's, and\n`bank_four_eyes_case_types` and `bank_reason_min` what the bank\nadded. `case_review_days` gives the jurisdiction's review window,\nthe bank's and the effective one; `bank_version` the active\noverlay. Without a tenant: the platform table only.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "description": "The bank whose overlay is merged in (or `X-Tenant-ID`).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The catalogue",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CaseWorkflow"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/compliance-cases/workflow/bank": {
      "get": {
        "operationId": "getCaseWorkflowBank",
        "tags": ["Screening"],
        "summary": "The bank's case workflow overlay, its pending change and its history",
        "description": "The active overlay, the pending change (with `can` for the\ncaller), the newest 50 versions and the newest 200 history events\n(requested, activated, rejected, withdrawn, superseded: who, when,\nwhy), and the review window (jurisdiction's and effective).\n\nReads: an `mlro` or `auditor` of the bank's cell, a `super_admin`\nin the platform scope, a service key; any other role 403\n`forbidden`. The tenant is required (`X-Tenant-ID` or `tenant_id`).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The overlay and its history",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CaseWorkflowBankState"
                }
              }
            }
          },
          "400": {
            "description": "No tenant"
          },
          "403": {
            "description": "`forbidden`: not a reader"
          }
        }
      },
      "post": {
        "operationId": "requestCaseWorkflowBankChange",
        "tags": ["Screening"],
        "summary": "Ask a second MLRO to activate a stricter case workflow",
        "description": "An `mlro` of the bank's cell (a staff session) proposes the bank's\nwhole overlay (DEC-0035 P1, migration 280): rules per step and case\ntype (`*`: every type) that add a second officer (`four_eyes`) or\nraise the shortest reason (`reason_min`, 10 to 2000), and a shorter\nreview window (`case_review_days`, at most the jurisdiction's). It\nonly tightens: four_eyes false where the platform gates, a reason\nminimum below 10, a second officer on a freeze (it stops money at\nonce), on `start`, `file_sar` (two people already) or\n`withdraw_sar`, a reason on a step without one, or a longer review\nwindow are 422 `tighten_only_violation` with the violations. The\ndatabase refuses the same for every writer. Four-eyes can be added\nto `escalate`, `propose_sar`, `close_no_sar`, `close_false_positive`\nand `close_incident`.\n\nThe change is pending until another `mlro` of the cell activates it\n(`/approve`); one change is pending at a time (409\n`workflow_change_pending`). An empty overlay takes the bank's own\ntightening away (never a platform rule), with the same approval.\nA `super_admin` reads only (403 `platform_read_only`); another role\n403 `mlro_required`; a service key 403 `session_required`. Audit\n1920.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["rules", "reason"],
                "properties": {
                  "rules": {
                    "type": "array",
                    "maxItems": 100,
                    "items": {
                      "$ref": "#/components/schemas/CaseWorkflowRule"
                    }
                  },
                  "case_review_days": {
                    "type": ["integer", "null"],
                    "minimum": 1
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 10,
                    "maxLength": 1000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The pending change",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CaseWorkflowVersion"
                }
              }
            }
          },
          "400": {
            "description": "`reason_required` (10 to 1000 characters), or no tenant"
          },
          "403": {
            "description": "`platform_read_only`, `mlro_required`, `session_required`, `person_required`"
          },
          "409": {
            "description": "`workflow_change_pending`: another change waits"
          },
          "422": {
            "description": "`tighten_only_violation`: the rule would loosen the platform table",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CaseWorkflowViolations"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/compliance-cases/workflow/bank/{versionId}/approve": {
      "post": {
        "operationId": "approveCaseWorkflowBankChange",
        "tags": ["Screening"],
        "summary": "A second MLRO activates the bank's workflow change",
        "description": "Another `mlro` of the bank's cell (never the requester: 403\n`four_eyes_required`, and a database CHECK for every writer)\nactivates the pending change; the active overlay is superseded.\nThe rules are checked again (422 `tighten_only_violation` when the\njurisdiction's review window shrank since; the change stays\npending). New cases are due by the effective review window; open\ncases keep their due date. Audit 1921 names both people.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "versionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "tenant_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string",
                    "maxLength": 1000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The active version",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CaseWorkflowVersion"
                }
              }
            }
          },
          "403": {
            "description": "`four_eyes_required`, `platform_read_only`, `mlro_required`, `session_required`"
          },
          "404": {
            "description": "Version not found (or another bank's)"
          },
          "409": {
            "description": "`workflow_change_not_pending`"
          },
          "422": {
            "description": "`tighten_only_violation`"
          }
        }
      }
    },
    "/api/v1/compliance-cases/workflow/bank/{versionId}/reject": {
      "post": {
        "operationId": "rejectCaseWorkflowBankChange",
        "tags": ["Screening"],
        "summary": "A second MLRO rejects the bank's workflow change, or the requester withdraws it",
        "description": "Another `mlro` of the bank's cell rejects with a reason (400\n`reason_required` without one); the requester's reject is a\nwithdrawal (reason optional). Audit 1922.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "versionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "tenant_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string",
                    "maxLength": 1000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The rejected or withdrawn version",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CaseWorkflowVersion"
                }
              }
            }
          },
          "400": {
            "description": "`reason_required`"
          },
          "403": {
            "description": "`four_eyes_required`, `platform_read_only`, `mlro_required`, `session_required`"
          },
          "404": {
            "description": "Version not found (or another bank's)"
          },
          "409": {
            "description": "`workflow_change_not_pending`"
          }
        }
      }
    },
    "/api/v1/compliance-cases/{caseId}/lift-freeze": {
      "post": {
        "operationId": "liftComplianceCaseFreeze",
        "tags": ["Screening"],
        "summary": "Ask a second MLRO to lift a case freeze",
        "description": "An MLRO of the cell or the platform scope asks; every lift waits for\nanother `mlro` of the bank's cell (four-eyes, DEC-0035): 202 with\nthe pending request, nothing lifted yet. The approval ends the\nfreeze window and thaws the subject through the freeze writer, with\nthe requester as the officer (`freeze_lifted`, audit 1407). The\nreason has at least 10 characters. While a request is pending on\nthe case, another lift or a disposition is 409 `approval_pending`;\na freeze and an assignment still work.\n\nThe tenant is required: the `X-Tenant-ID` header or the `tenant_id`\nquery parameter (400 without either).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "caseId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "X-Tenant-ID",
            "in": "header",
            "description": "The case's tenant; required unless `tenant_id` is given.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "tenant_id",
            "in": "query",
            "description": "The case's tenant; required unless `X-Tenant-ID` is given.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["reason"],
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 10
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Waiting for a second officer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CaseApprovalAccepted"
                }
              }
            }
          },
          "400": {
            "description": "Invalid case id or tenant, or a reason under 10 characters"
          },
          "403": {
            "description": "`forbidden_role` (DEC-0043): not the bank's `mlro` (the platform scope reads cases, it does not decide them); `person_required` for a service call without a person"
          },
          "404": {
            "description": "Case not found"
          },
          "409": {
            "description": "`approval_pending`: a request already waits on the case. `no_live_freeze`: nothing to lift.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["error"],
                  "properties": {
                    "error": {
                      "type": "string",
                      "enum": ["approval_pending", "no_live_freeze"]
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/compliance-cases/{caseId}/dispose": {
      "post": {
        "operationId": "disposeComplianceCase",
        "tags": ["Screening"],
        "summary": "Record a compliance case disposition",
        "description": "The officer's disposition (`sar`, `no_sar`, `freeze`, `escalate`,\n`false_positive`) with a written rationale of at least 10 characters\n(BR-EF-031). Every disposition is a step of the transition table\n(`GET /api/v1/compliance-cases/workflow`) and is refused with 409\n`transition_not_allowed` from a status that is not one of its\nfrom-states, or on a case type it does not apply to: `no_sar` and\n`false_positive` close the case; `sar` proposes a report\n(pending_filing; with `close: true` it closes the case as SAR, which\nneeds a filed report, else 409 `sar_not_filed`); `escalate` keeps\nthe case open (with `close: true` only an `incident` closes); a\n`freeze` never closes, never changes a pending filing and starts an\nopen case. `close` defaults to false. No case closes as `no_sar` or\n`false_positive` while a report linked to it is a draft, locked or\nfiled (409 `sar_pending`: withdraw the report first, with a\nrationale). The case row, the spend stop, the filing drafts, the\nalert it resolves, the events and the audit rows (disposition,\nstatuses and the SHA-256 of the rationale) are written in one unit:\na failed event write fails the decision and writes nothing. On a case\nthat decides its screening result, `freeze` confirms the match and\n`false_positive` clears it (ES-case-decides-screening).\n\nA `sanctions_hit` case does not close while its freeze is live: a\ndisposition that would close it is refused with 409\n`case_freeze_live` and nothing is written. The officer lifts the\nfreeze first (`POST /api/v1/compliance-cases/{caseId}/lift-freeze`,\na thaw with a reason); the case stays open, and closing it then\nworks (ES-sanctions-close-needs-lift). The rule is a database\ntrigger (migration 234), so it holds for every writer. Since\nmigration 246 (DEC-0035) no case of any type closes while its freeze\nis live (409 `case_freeze_live`): the lift, approved by a second\nMLRO, comes first.\n\nFour-eyes (DEC-0035): `false_positive` and `no_sar` on a\n`sanctions_hit`, `screening_alert` or `transfer_block` case, or on\nany case that decides a sanctions or transfer alert or a linked\nscreening result, answer 202 with a\npending request for another `mlro` of the bank's cell; nothing is\ndecided until it is approved (the approval closes the case and\ndecides its screening result, with the requester as the officer).\n`close` does not apply to it. Every other disposition is unchanged.\nWhile a request is pending on the case, every disposition except\n`freeze` is 409 `approval_pending`.\n\nA bank's workflow overlay (migration 280, `GET\n/api/v1/compliance-cases/workflow`) may gate more steps (`escalate`,\n`sar` without `close`, `no_sar`, `false_positive` on more case\ntypes, an incident's closing `escalate`): they answer 202 the same\nway and the approval runs the disposition with the requester as the\nofficer. A rationale shorter than the bank's minimum for the step\nis 400 `rationale_too_short`.\n\nThe tenant is required: the `X-Tenant-ID` header or the `tenant_id`\nquery parameter (400 without either).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "caseId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "X-Tenant-ID",
            "in": "header",
            "description": "The case's tenant; required unless `tenant_id` is given.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "tenant_id",
            "in": "query",
            "description": "The case's tenant; required unless `X-Tenant-ID` is given.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["disposition", "rationale", "band_decision"],
                "properties": {
                  "disposition": {
                    "type": "string",
                    "enum": [
                      "sar",
                      "no_sar",
                      "freeze",
                      "escalate",
                      "false_positive"
                    ]
                  },
                  "rationale": {
                    "type": "string",
                    "minLength": 10
                  },
                  "band_decision": {
                    "type": "string",
                    "enum": ["agree", "override"]
                  },
                  "close": {
                    "type": "boolean",
                    "default": false
                  },
                  "actor": {
                    "type": "string",
                    "description": "Service callers only; staff calls use the session email."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The case row after the disposition"
          },
          "202": {
            "description": "A gated false positive waits for a second officer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CaseApprovalAccepted"
                }
              }
            }
          },
          "400": {
            "description": "Missing or invalid disposition, rationale or band decision"
          },
          "403": {
            "description": "`forbidden_role` (DEC-0043): not the bank's `mlro`, the platform scope included. No officer identity (`officer_required`); a gated false positive without a person (`person_required`)"
          },
          "404": {
            "description": "Case not found"
          },
          "409": {
            "description": "`case_freeze_live`: the disposition would close a case whose\nfreeze is live (any case type), or mark the screening result of\na case under a live freeze a false positive; lift the freeze\nfirst. `case_closed`: the case is closed.\n`screening_result_decided`: the result was decided elsewhere a\nmoment ago. `approval_pending`: a request for a second officer\nwaits on the case. `transition_not_allowed`: the case's status\nor type does not allow the step. `sar_pending`: a linked report\nis a draft, locked or filed. `sar_not_filed`: closing as SAR\nneeds a filed report.\n",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["error"],
                  "properties": {
                    "error": {
                      "type": "string",
                      "enum": [
                        "case_freeze_live",
                        "case_closed",
                        "screening_result_decided",
                        "approval_pending",
                        "transition_not_allowed",
                        "sar_pending",
                        "sar_not_filed"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "The case's subject cannot be frozen (`freeze_subject_not_accountable`)"
          }
        }
      }
    },
    "/api/v1/compliance-cases/{caseId}/start": {
      "post": {
        "operationId": "startComplianceCase",
        "tags": ["Screening"],
        "summary": "Start investigating a case",
        "description": "open -> investigating (the `start` step of the transition table),\nwith a strict `started` event and its audit row. The officer is the\nsession's; the case goes to them when nobody holds it. 409\n`transition_not_allowed` from any other status, `case_closed` on a\nclosed case.\n\nThe tenant is required: the `X-Tenant-ID` header or the `tenant_id`\nquery parameter (400 without either).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "caseId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "X-Tenant-ID",
            "in": "header",
            "description": "The case's tenant; required unless `tenant_id` is given.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "tenant_id",
            "in": "query",
            "description": "The case's tenant; required unless `X-Tenant-ID` is given.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The case row, investigating"
          },
          "403": {
            "description": "`officer_required`: no officer in the session"
          },
          "404": {
            "description": "Case not found"
          },
          "409": {
            "description": "`transition_not_allowed` or `case_closed`"
          }
        }
      }
    },
    "/api/v1/compliance-cases/overdue-counts": {
      "get": {
        "operationId": "countOverdueComplianceCases",
        "tags": ["Screening"],
        "summary": "Cases and reports past their deadline (counts)",
        "description": "The MLRO cockpit's counts in the bank's scope: open cases past\n`due_at` and unfiled reports (draft, locked) past their reporting\ndeadline (detection + `sar_sla_hours`). `sars_overdue` is null for a\ncaller who does not read reports (only a cell MLRO, the platform\nscope or a service key does). DEC-0035 amendment 2026-10-07.\n",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "description": "The bank; required unless `X-Tenant-ID` is given.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The counts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["overdue_cases", "sars_overdue"],
                  "properties": {
                    "overdue_cases": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "sars_overdue": {
                      "type": ["integer", "null"],
                      "minimum": 0
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "No tenant"
          }
        }
      }
    },
    "/api/v1/compliance-cases/internal/overdue": {
      "post": {
        "operationId": "sweepOverdueComplianceCases",
        "tags": ["Screening"],
        "summary": "Flag cases and reports past their deadline (service key)",
        "description": "The overdue sweep of the workflows scheduler\n`ComplianceCaseOverdueScheduler` (daily), a service key only (403\n`service_key_required` otherwise). Every tenant in its own\ntransaction (with `X-Tenant-ID` that tenant only): each open case\npast `due_at` that was not flagged yet gets `overdue_at`, a strict\n`overdue` case event naming the recipients, and its audit row; each\nsuch case and each unfiled report (draft, locked) past its reporting\ndeadline (detection + the jurisdiction's `sar_sla_hours`) gets one\nnotice (migration 286; a report's audit row is 1701 `sar.overdue`).\nThe answer lists per tenant the newly flagged case and report ids\nand the open notices (at most 200 per tenant, the least recently\ntried first): ids, kinds and due instants, never an address, a\nsubject or a case type. A notice is answered again until its outcome\nis recorded, so a failed e-mail is retried by the next run (DEC-0035\namendment 2026-10-07). A jurisdiction `sar_sla_hours` that is not a\nwhole number of hours counts as unset and is logged.\n",
        "security": [
          {
            "ServiceKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "What the sweep flagged and the notices to send",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["items", "tenants", "failed"],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "tenant_id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "flagged": {
                            "description": "Cases flagged by this sweep",
                            "type": "array",
                            "items": {
                              "type": "string",
                              "format": "uuid"
                            }
                          },
                          "sars_flagged": {
                            "description": "Reports flagged by this sweep",
                            "type": "array",
                            "items": {
                              "type": "string",
                              "format": "uuid"
                            }
                          },
                          "notices": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                "kind": {
                                  "type": "string",
                                  "enum": ["case", "sar"]
                                },
                                "subject_id": {
                                  "description": "The case or the report",
                                  "type": "string",
                                  "format": "uuid"
                                },
                                "due_at": {
                                  "type": "string",
                                  "format": "date-time"
                                }
                              }
                            }
                          }
                        }
                      }
                    },
                    "tenants": {
                      "type": "integer"
                    },
                    "failed": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`service_key_required`"
          }
        }
      }
    },
    "/api/v1/compliance-cases/internal/overdue/notices/{noticeId}": {
      "get": {
        "operationId": "getComplianceOverdueNotice",
        "tags": ["Screening"],
        "summary": "The recipients of an overdue notice (service key)",
        "description": "For the scheduler's e-mail, a service key and the notice's tenant in\n`X-Tenant-ID` only. The recipients are the active `mlro` members of\nthe bank's cell (never a super_admin, never anyone outside the cell)\nthat the notice has not reached yet, with the primary language of\nthe bank's jurisdiction. `skip` with a `reason` and no recipients\nwhen the outcome was recorded already (`recorded`), the case closed\nor the report was filed or withdrawn (`resolved`), or the cell has\nno active MLRO (`no_recipients`).\n",
        "security": [
          {
            "ServiceKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "noticeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "X-Tenant-ID",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The notice and its recipients",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "skip",
                    "kind",
                    "subject_id",
                    "due_at",
                    "recipients"
                  ],
                  "properties": {
                    "skip": {
                      "type": "boolean"
                    },
                    "reason": {
                      "type": ["string", "null"],
                      "enum": ["recorded", "resolved", "no_recipients", null]
                    },
                    "kind": {
                      "type": "string",
                      "enum": ["case", "sar"]
                    },
                    "subject_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "due_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "attempts": {
                      "description": "Tries recorded so far",
                      "type": "integer"
                    },
                    "delivered": {
                      "description": "MLROs the notice has reached",
                      "type": "integer"
                    },
                    "recipients": {
                      "description": "The cell MLROs the notice has not reached yet",
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "email": {
                            "type": "string"
                          },
                          "locale": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid notice id or no `X-Tenant-ID`"
          },
          "403": {
            "description": "`service_key_required`"
          },
          "404": {
            "description": "No such notice of this bank"
          }
        }
      }
    },
    "/api/v1/compliance-cases/internal/overdue/notices/{noticeId}/outcome": {
      "post": {
        "operationId": "recordComplianceOverdueNoticeOutcome",
        "tags": ["Screening"],
        "summary": "Record one try of an overdue notice (service key)",
        "description": "One try: `attempts` + 1, `last_attempt_at`, and the addresses it\nreached (`delivered`, never asked again). `sent` (every MLRO\nreached), `skipped` (`resolved`, `no_recipients`) and `failed`\n(`rejected`: an address refused for good) close the notice;\n`attempt` keeps it open, and the third try closes it as `failed`\n(`attempts`). A notice closed as `no_recipients` or `failed` counts\nin `finance_api_case_overdue_notice_problems_total` (alert\n`CaseOverdueNoticeUndelivered`). A call on a closed notice answers\n`recorded: false` and changes nothing. A service key and the\nnotice's tenant in `X-Tenant-ID` only.\n",
        "security": [
          {
            "ServiceKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "noticeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "X-Tenant-ID",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["outcome"],
                "properties": {
                  "outcome": {
                    "type": "string",
                    "enum": ["attempt", "sent", "skipped", "failed"]
                  },
                  "reason": {
                    "description": "skipped: resolved or no_recipients; failed: rejected; none for sent and attempt",
                    "type": ["string", "null"],
                    "enum": ["resolved", "no_recipients", "rejected", null]
                  },
                  "delivered": {
                    "description": "Addresses this try reached",
                    "type": "array",
                    "maxItems": 1000,
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Whether this call recorded it",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "recorded": {
                      "type": "boolean"
                    },
                    "outcome": {
                      "description": "The notice's outcome now (null while open)",
                      "type": ["string", "null"],
                      "enum": ["sent", "skipped", "failed", null]
                    },
                    "reason": {
                      "type": ["string", "null"]
                    },
                    "attempts": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid notice id, outcome, reason, address or `X-Tenant-ID`"
          },
          "403": {
            "description": "`service_key_required`"
          },
          "404": {
            "description": "No such notice of this bank"
          }
        }
      }
    },
    "/api/v1/compliance-cases/{caseId}/freeze": {
      "post": {
        "operationId": "freezeComplianceCase",
        "tags": ["Screening"],
        "summary": "Freeze what a compliance case is about",
        "description": "The spend stop of the case's subject through the freeze writer, with\nthe tipping-off lock. Without `freeze_until` the case's regime\ndefault applies (CH: 5 days, EU: none). A `sanctions_hit` case is\nnever dated: its freeze lasts until an officer lifts it, so a\n`freeze_until` sent for one is refused with 409\n`sanctions_freeze_undated` before anything is written\n(ES-sanctions-close-needs-lift).\n\nA freeze never shortens a live one (DEC-0035): a `freeze_until` on a\ndated live freeze keeps the later end, and an undated live freeze\nstays undated. Only the lift, approved by a second MLRO, ends a\nfreeze early. A freeze is never blocked by a pending request.\n\nThe tenant is required: the `X-Tenant-ID` header or the `tenant_id`\nquery parameter (400 without either).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "caseId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "X-Tenant-ID",
            "in": "header",
            "description": "The case's tenant; required unless `tenant_id` is given.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "tenant_id",
            "in": "query",
            "description": "The case's tenant; required unless `X-Tenant-ID` is given.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "freeze_until": {
                    "type": "string",
                    "description": "ISO date or timestamp in the future; not for a sanctions_hit case."
                  },
                  "actor": {
                    "type": "string",
                    "description": "Service callers only; staff calls use the session email."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The case row after the freeze"
          },
          "400": {
            "description": "Invalid case id, tenant or freeze date"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "404": {
            "description": "Case not found"
          },
          "409": {
            "description": "`sanctions_freeze_undated`: a date was sent for a sanctions case.\n`case_freeze_live`: the write would date or retype a sanctions\ncase under a live freeze (migration 234). `case_closed`: the case\nis closed.\n",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["error"],
                  "properties": {
                    "error": {
                      "type": "string",
                      "enum": [
                        "sanctions_freeze_undated",
                        "case_freeze_live",
                        "case_closed"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "The case's subject cannot be frozen (`freeze_subject_not_accountable`)"
          }
        }
      }
    },
    "/api/v1/screening/alerts": {
      "get": {
        "operationId": "listScreeningAlerts",
        "tags": ["Screening"],
        "summary": "List monitoring alerts",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": ["open", "acknowledged", "escalated", "resolved"]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "kind",
            "in": "query",
            "description": "list_hits: hits on a screening list only (sanctions, PEP, adverse media), never a transaction-monitoring (tm_shadow) alert. Without it every alert is returned.",
            "schema": {
              "type": "string",
              "enum": ["list_hits"]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Alerts list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "alerts": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ScreeningAlert"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/screening/alerts/{alertId}": {
      "patch": {
        "operationId": "resolveScreeningAlert",
        "tags": ["Screening"],
        "summary": "Decide a monitoring alert",
        "description": "The MLRO decides a list-match alert of a watched customer:\n`resolved` closes it as a false positive, `escalated` hands it to a\ncase, `acknowledged` notes it was seen. The officer's reason is\nrequired (10 to 2000 characters) and recorded with the officer (the\nsession) and an audit event. An alert only moves forward (open ->\nacknowledged -> escalated -> resolved); a decided alert answers 409.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "alertId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["status", "notes"],
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": ["acknowledged", "escalated", "resolved"]
                  },
                  "notes": {
                    "type": "string",
                    "minLength": 10,
                    "maxLength": 2000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Alert decided",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "alert_type": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": ["acknowledged", "escalated", "resolved"]
                    },
                    "resolution": {
                      "type": "string",
                      "enum": ["false_positive", "escalated", "acknowledged"]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`{\"error\":\"screening_reason_required\"}`, or a status that is not a decision"
          },
          "403": {
            "description": "`forbidden_role` (staff route gate, DEC-0043); Not an MLRO (or the platform scope), or no officer identity"
          },
          "404": {
            "description": "Alert not found"
          },
          "409": {
            "description": "`{\"error\":\"screening_alert_decided\"}`: decided already"
          }
        }
      }
    },
    "/api/v1/screening/stats": {
      "get": {
        "operationId": "getScreeningStats",
        "tags": ["Screening"],
        "summary": "Screening statistics dashboard",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Screening statistics",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScreeningStats"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/screening/monitoring/profile": {
      "post": {
        "operationId": "createMonitoringProfile",
        "tags": ["Screening"],
        "summary": "Create a monitoring profile for continuous screening",
        "description": "Internal endpoint used by the workflow engine to register a subject\nfor continuous sanctions monitoring via the screening provider.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "X-Tenant-ID",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["subject_id", "subject_name"],
                "properties": {
                  "subject_type": {
                    "type": "string",
                    "enum": ["customer", "beneficiary", "ubo"],
                    "default": "customer"
                  },
                  "subject_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "subject_name": {
                    "type": "string"
                  },
                  "data_sources": {
                    "type": "string",
                    "default": "SANCTIONS-LISTS,PEP"
                  },
                  "min_score": {
                    "type": "string",
                    "default": "0.85"
                  },
                  "date_of_birth": {
                    "type": "string",
                    "format": "date"
                  },
                  "nationality": {
                    "type": "string",
                    "maxLength": 2
                  },
                  "country": {
                    "type": "string",
                    "maxLength": 2
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Monitoring profile created"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          }
        }
      }
    },
    "/api/v1/screening/monitoring/untracked": {
      "get": {
        "operationId": "listUntrackedSubjects",
        "tags": ["Screening"],
        "summary": "List subjects without monitoring profiles",
        "description": "Internal endpoint used by the scheduled monitoring workflow to find\ncleared subjects that need monitoring profile creation.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "List of untracked subjects"
          }
        }
      }
    },
    "/api/v1/screening/monitoring/alert": {
      "post": {
        "operationId": "processMonitoringAlerts",
        "tags": ["Screening"],
        "summary": "Poll and process monitoring alerts",
        "description": "Internal endpoint used by the scheduled monitoring workflow to poll\nthe screening provider for new alerts and persist them in the alerts table.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "X-Tenant-ID",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Alerts processed"
          }
        }
      }
    },
    "/api/v1/accounts/opening": {
      "post": {
        "operationId": "staffOpenAccount",
        "tags": ["Accounts"],
        "summary": "Open an account through the AccountCreation workflow",
        "description": "A staff session opens an account (IBAN, ledger account, IBAN\nregistry) through Restate AccountCreation, which finance-api starts\nafter its staff route gate with the session's officer as acting user,\nthe bank of the request and its internal secret (final review L1 of\nfeature/super-admin-assist). `bank_admin`, or the platform\n`super_admin` on the bank's behalf with `X-Tenant-ID` and a reason\n(see \"Platform assist\"); the reason travels with the workflow's\ncalls. The workflow key and the ledger account id are derived from\nthe bank and the `Idempotency-Key`, so a retry reaches the same run\nand the same account. A `customer_id` must be the bank's (404\n`customer_not_found`).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/ChangeReason"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["name", "currency"],
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 255
                  },
                  "currency": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 3
                  },
                  "country": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 2
                  },
                  "account_type": {
                    "type": "string",
                    "maxLength": 40
                  },
                  "customer_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "owner_id": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "tenant_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "must be the bank of the request"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The workflow's answer (account_id, iban, status)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "result": {
                      "type": "object",
                      "additionalProperties": true
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`name_required`, `currency_required`, `invalid_field`, `invalid_id`, `idempotency_key_required`, `reason_required`, `tenant_required`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "404": {
            "description": "`customer_not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "`account_creation_failed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/accounts": {
      "get": {
        "operationId": "listAccounts",
        "tags": ["Accounts"],
        "summary": "List accounts with IBAN registry and ownership data",
        "description": "A customer JWT lists its own accounts. Staff and services list the\nbank's accounts with every filter and the search applied in SQL,\nnewest first; `total` is the number of accounts that match the\nfilters, not the length of the page. A malformed filter is a 400,\nnever read as \"no filter\".\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "customer_id",
            "in": "query",
            "required": false,
            "description": "Only this customer's accounts (UUID).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "tenant_id",
            "in": "query",
            "required": false,
            "description": "The bank (UUID). Used only when the request has no tenant of its\nown (the platform scope); a bank session always lists its own bank.\n",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["active", "frozen", "closed", "woff", "pending_approval"]
            }
          },
          {
            "name": "currency",
            "in": "query",
            "required": false,
            "description": "ISO 4217 code, upper case.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Z]{3}$"
            }
          },
          {
            "name": "account_type",
            "in": "query",
            "required": false,
            "description": "Ledger account type, e.g. `customer_emoney`, `nostro`, `safeguarding`.",
            "schema": {
              "type": "string",
              "pattern": "^[a-z_]{1,40}$"
            }
          },
          {
            "name": "exclude_customer_accounts",
            "in": "query",
            "required": false,
            "description": "`true`: leave out customer e-money accounts (the bank's own accounts only).",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "Case-insensitive text found in the account name, the IBAN (spaces\nignored), the ledger or registry id, or the owner's name. Taken\nliterally (no wildcards); at most 200 characters.\n",
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Page size; 100 when absent, at most 200.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "description": "Sort column: `created` (default), `name`, `type`, `status` or\n`currency`. Anything else is a 400.\n",
            "schema": {
              "type": "string",
              "enum": ["created", "name", "type", "status", "currency"]
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "`asc` or `desc`; absent: newest first for `created`, else A to Z.",
            "schema": {
              "type": "string",
              "enum": ["asc", "desc"]
            }
          }
        ],
        "responses": {
          "400": {
            "description": "A malformed filter, search or paging value."
          },
          "200": {
            "description": "Account list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "accounts": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Account"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createAccount",
        "tags": ["Accounts"],
        "summary": "Create ledger account",
        "description": "Creates a ledger account with corresponding metadata. Account types\ncover customer e-money, platform fees, safeguarding, nostro, suspense,\nand float. For the full\naccount opening workflow including IBAN assignment and compliance\nchecks, use the durable execution endpoint.\n\nOwnership (DEC-0026): the account's owner is recorded only when\nTigerBeetle created it in this call: the request tenant, or the\nplatform for `internal`. An existing id is never claimed or\nre-pointed. Only the platform (a service acting for nobody, or the\nplatform scope) creates `internal` accounts. Service calls may carry\n`X-Acting-User-ID` (the Restate AccountCreation workflow does):\nfinance-api then applies that operator's scope instead of platform\nrights.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateAccountRequest"
              }
            }
          }
        },
        "responses": {
          "400": {
            "description": "`{\"error\":\"tenant_required\"}`: a non-internal account needs the request tenant (X-Tenant-ID, JWT or the acting operator); never a body field"
          },
          "403": {
            "description": "`{\"error\":\"forbidden\"}`: `tenant_type` internal (platform account) requested by a caller that is not the platform (service acting for nobody, or platform scope); `{\"error\":\"reserved_account_id\"}`: a server-reserved id (0x1..0xFF or top 16 bits 0xFFFF) by a non-platform caller; `{\"error\":\"actor_not_permitted\"}` for a service call acting for an operator who may not act for that tenant"
          },
          "409": {
            "description": "`{\"error\":\"account_exists\"}`: the id already exists and is not a retry of this owner's own create (its owner row names another owner or none)"
          },
          "201": {
            "description": "Account created"
          }
        }
      }
    },
    "/api/v1/accounts/{accountId}": {
      "get": {
        "operationId": "getAccount",
        "tags": ["Accounts"],
        "summary": "Retrieve account details by registry ID or ledger ID",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AccountId"
          }
        ],
        "responses": {
          "200": {
            "description": "Account details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Account"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateAccount",
        "tags": ["Accounts"],
        "summary": "Update account metadata",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AccountId"
          }
        ],
        "responses": {
          "200": {
            "description": "Account updated"
          }
        }
      }
    },
    "/api/v1/accounts/{accountId}/freeze": {
      "post": {
        "operationId": "freezeAccount",
        "tags": ["Accounts"],
        "summary": "Freeze account (blocks all debits and credits)",
        "description": "Immediately blocks all financial operations on the account. Used for\nfraud prevention, regulatory holds, or court orders. The freeze action\nis recorded in the immutable audit trail with the initiating actor's identity.\nFrozen accounts retain their balance but cannot participate in transfers.\nA freeze is never gated. Staff send a reason category and a reason of\nat least 10 characters; the officer of the session and the reason are\nwritten to the audit rows (400 `reason_required` without them).\n\nThe `accountId` parameter accepts either an IBAN registry integer PK or\na hex-encoded ledger engine account ID. The backend resolves the ID via\n`finance_iban_registry.workflow_id` lookup with hex fallback.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AccountId"
          }
        ],
        "requestBody": {
          "description": "Staff only (a customer or a service sends no body).",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OfficerReason"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Account frozen (recorded in the audit trail)"
          },
          "400": {
            "description": "`reason_required` (staff)"
          }
        }
      }
    },
    "/api/v1/accounts/{accountId}/unfreeze": {
      "post": {
        "operationId": "unfreezeAccount",
        "tags": ["Accounts"],
        "summary": "Unfreeze account (restore operational status; staff need a second officer)",
        "description": "Staff: the request is recorded and a second officer decides\n(202, migration 268; `POST /api/v1/ops-approvals/{id}/approve` runs\nthe unfreeze with the requester as actor). Refused when the account\nis not frozen. A service without an officer unfreezes at once; a live\ncompliance stop still holds the account (`held: true`).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AccountId"
          }
        ],
        "requestBody": {
          "description": "Staff only (a customer or a service sends no body).",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OfficerReason"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Account unfrozen (service)"
          },
          "202": {
            "description": "Staff request recorded; a second officer decides (`/api/v1/ops-approvals`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpsApprovalPending"
                }
              }
            }
          },
          "400": {
            "description": "`reason_required`: a reason category and a reason of at least 10 characters"
          },
          "403": {
            "description": "`forbidden_role` (only the platform scope or a cell `bank_admin` asks), `person_required`"
          },
          "409": {
            "description": "`approval_pending` (a request already waits on this account), `not_frozen`, `already_closed`, `invalid_status`"
          },
          "422": {
            "description": "`balance_not_zero`, `pending_transfers`, `primary_account`"
          }
        }
      }
    },
    "/api/v1/accounts/{accountId}/write-off": {
      "post": {
        "operationId": "writeOffAccount",
        "tags": ["Accounts"],
        "summary": "Write off account (BR-EF-015, terminal WOFF state)",
        "description": "Transitions the account to `woff` (written-off) status. Only accounts\nin `active` or `frozen` status can be written off. Records the IFRS 9\nreason classification (`bad_debt`, `fraud`, `deceased`, `bankruptcy`,\n`regulatory`), captures the current ledger balance as the write-off\namount, and maps the reason to an ISO 20022 return code (AC06, MD07,\nRR04). The ISO code is stored per-account and used for automated SEPA\nrejection responses. An immutable audit event (type 104) is created\nwith the actor, the cause, the amount and the rationale.\n\nStaff: the request is recorded and a second officer decides (202,\nmigration 268). Staff send `woff_reason` (the cause), a reason\ncategory and a written rationale (`reason`, at least 10 characters).\nA service sends `reason` (the cause) and runs at once. An account\nwithout a metadata row is refused (409 `invalid_status`).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AccountId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "description": "Service: the cause. Staff: the written rationale (at least 10 characters).",
                    "type": "string"
                  },
                  "woff_reason": {
                    "$ref": "#/components/schemas/WoffReason"
                  },
                  "reason_category": {
                    "type": "string",
                    "pattern": "^[a-z_]{2,40}$"
                  },
                  "rationale": {
                    "type": "string",
                    "description": "Service: optional rationale for the audit row."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Account written off",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "status": {
                      "type": "string",
                      "example": "woff"
                    },
                    "woff_reason": {
                      "type": "string"
                    },
                    "woff_amount": {
                      "type": "string"
                    },
                    "iso_return_code": {
                      "type": "string",
                      "example": "AC06"
                    }
                  }
                }
              }
            }
          },
          "202": {
            "description": "Staff request recorded; a second officer decides (`/api/v1/ops-approvals`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpsApprovalPending"
                }
              }
            }
          },
          "400": {
            "description": "`reason_required`, `woff_reason_required` (staff)"
          },
          "422": {
            "description": "Invalid status transition (only active/frozen -> woff)"
          }
        }
      }
    },
    "/api/v1/accounts/{accountId}/blocked-transactions": {
      "get": {
        "operationId": "listBlockedTransactions",
        "tags": ["Accounts"],
        "summary": "List blocked transaction attempts (audit trail)",
        "description": "Returns the log of transfer attempts that were blocked by the account\nguard due to account status (frozen, closed, woff). Each entry records\nthe direction (inbound/outbound), attempted amount, currency, account\nstatus at time of block, error code, ISO 20022 return code, and\noriginating channel. Designed to support operational resilience and\nincident reporting (FINMA\nCircular 2023/1), subject to operational implementation and legal\nvalidation.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AccountId"
          }
        ],
        "responses": {
          "200": {
            "description": "Blocked transaction log (max 100 entries, newest first)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "blocked_transactions": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/BlockedTransaction"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/accounts/{accountId}/close": {
      "post": {
        "operationId": "closeAccount",
        "tags": ["Accounts"],
        "summary": "Close account (terminal state, requires zero balance)",
        "description": "Permanently closes the account. Requires zero available balance and no\npending transfers. Closed accounts cannot be reopened. Closure is\nrecorded in the immutable audit trail. For safeguarding accounts,\nclosure requires prior fund redistribution to maintain safeguarding\nobligations. Staff: the request is recorded and a second officer\ndecides (202, migration 268); the balance is checked when asked and\nagain when approved. A primary account is never closed (422\n`primary_account`).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AccountId"
          }
        ],
        "requestBody": {
          "description": "Staff only (a customer or a service sends no body).",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OfficerReason"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Account closed (service)"
          },
          "202": {
            "description": "Staff request recorded; a second officer decides (`/api/v1/ops-approvals`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpsApprovalPending"
                }
              }
            }
          },
          "400": {
            "description": "`reason_required`: a reason category and a reason of at least 10 characters"
          },
          "403": {
            "description": "`forbidden_role` (only the platform scope or a cell `bank_admin` asks), `person_required`"
          },
          "409": {
            "description": "`approval_pending` (a request already waits on this account), `not_frozen`, `already_closed`, `invalid_status`"
          },
          "422": {
            "description": "`balance_not_zero`, `pending_transfers`, `primary_account`"
          }
        }
      }
    },
    "/api/v1/accounts/{accountId}/status-detail": {
      "get": {
        "operationId": "getAccountStatusDetail",
        "tags": ["Accounts"],
        "summary": "Why the account is in its state (freezes, stops, write-off)",
        "description": "Why the account is in its state, for the staff account page. Staff and\nservices only (a customer gets 403). `events`: the last 10 freezes,\nunfreezes, refused unfreezes, closures and write-offs of the account, its\nledger accounts and freezes of the whole customer, newest first, with the\nactor and the reason as recorded. `stops`: what keeps it frozen whatever\nan officer asks (customer suspended, a compliance hold, live freeze\ncases: counted for every role, listed by id for the mlro, the auditor,\nthe platform and services). `write_off`: a ledger account's write-off.\nAnother bank's account is not found.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AccountId"
          }
        ],
        "responses": {
          "200": {
            "description": "The account's status story",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountStatusDetail"
                }
              }
            }
          },
          "400": {
            "description": "Not an account id."
          },
          "403": {
            "description": "A customer, or a role without access to accounts."
          },
          "404": {
            "description": "No such account in this bank."
          }
        }
      }
    },
    "/api/v1/accounts/{accountId}/balances": {
      "get": {
        "operationId": "getAccountBalances",
        "tags": ["Accounts"],
        "summary": "Retrieve real-time account balances from ledger",
        "description": "Returns the account's current balance state directly from the ledger,\nreflecting all committed transfers. Includes available balance, pending\ndebits (reserved by holds), pending credits, and cumulative posted\namounts. Balances are in minor units (cents) as 64-bit integers.\nPending credits include incoming direct debit credits held until\ntheir holding period ends (HoldingPeriods); they are part of\n`total_balance`, not of `available_balance`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AccountId"
          }
        ],
        "responses": {
          "200": {
            "description": "Account balances",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountBalance"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/accounts/{accountId}/transactions": {
      "get": {
        "operationId": "getAccountTransactions",
        "tags": ["Accounts"],
        "summary": "Retrieve account transaction history",
        "description": "Returns the transfers affecting this ledger account (hex id, any\ncase), from transfer metadata. `amount` is negative when this\naccount is debited.\n\nKeyset paging (DEC-0029): newest first, `created_at` descending then\nthe row id descending. Follow `next_cursor` while `has_more` is\ntrue; a page never skips or repeats a row, also when rows share\n`created_at`. A filter change starts from the first page.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AccountId"
          },
          {
            "$ref": "#/components/parameters/HistoryLimit"
          },
          {
            "$ref": "#/components/parameters/HistoryCursor"
          },
          {
            "$ref": "#/components/parameters/HistoryAccountId"
          },
          {
            "$ref": "#/components/parameters/HistoryDirection"
          },
          {
            "$ref": "#/components/parameters/HistoryFrom"
          },
          {
            "$ref": "#/components/parameters/HistoryTo"
          },
          {
            "$ref": "#/components/parameters/HistoryTzOffset"
          },
          {
            "$ref": "#/components/parameters/HistoryStatus"
          },
          {
            "$ref": "#/components/parameters/HistoryCurrency"
          },
          {
            "$ref": "#/components/parameters/HistoryEventType"
          },
          {
            "$ref": "#/components/parameters/HistoryQuery"
          },
          {
            "$ref": "#/components/parameters/HistoryQueryType"
          },
          {
            "$ref": "#/components/parameters/HistoryAmountMin"
          },
          {
            "$ref": "#/components/parameters/HistoryAmountMax"
          }
        ],
        "responses": {
          "200": {
            "description": "One page of the transaction list",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/HistoryPage"
                    },
                    {
                      "type": "object",
                      "required": ["transfers"],
                      "properties": {
                        "transfers": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Transfer"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HistoryBadRequest"
          },
          "422": {
            "$ref": "#/components/responses/HistorySearchTooBroad"
          },
          "429": {
            "$ref": "#/components/responses/HistorySearchBusy"
          },
          "500": {
            "$ref": "#/components/responses/HistoryFailed"
          },
          "503": {
            "$ref": "#/components/responses/HistoryUnavailable"
          }
        }
      }
    },
    "/api/v1/wallets": {
      "get": {
        "operationId": "listWallets",
        "tags": ["Wallets"],
        "summary": "List wallets",
        "description": "A customer lists their own wallets. Staff and services list the\ntenant's, newest first, filtered over every row (`total` counts the\nmatches): `status`, `currency`, `type` and `search` (free text over\nthe account name, its IBAN and the customer's name, percent-decoded,\n`%` and `_` literal). Rows carry `customer_name` and `tenant_id`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "status",
            "description": "active, frozen, closing or closed; or `woff` (a ledger account of\nthe wallet is written off) or `pending_approval` (a change of the\nwallet or one of its ledger accounts waits for a second officer).\n",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "currency",
            "description": "ISO 4217 code.",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "type",
            "description": "personal or business.",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "search",
            "description": "Free text over name, IBAN and customer name.",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "description": "At most 200 (default 50).",
            "schema": {
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "offset",
            "description": "Rows to skip.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "sort",
            "description": "Sort column: `created` (default), `name`, `customer`, `status` or\n`currency`. Anything else is a 400.\n",
            "schema": {
              "type": "string",
              "enum": ["created", "name", "customer", "status", "currency"]
            }
          },
          {
            "in": "query",
            "name": "order",
            "description": "`asc` or `desc`; absent: newest first for `created`, else A to Z.",
            "schema": {
              "type": "string",
              "enum": ["asc", "desc"]
            }
          }
        ],
        "responses": {
          "400": {
            "description": "An unknown sort column or direction."
          },
          "200": {
            "description": "Wallet list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "wallets": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Wallet"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createWallet",
        "tags": ["Wallets"],
        "summary": "Create wallet (one currency, one IBAN)",
        "description": "Creates a wallet in one currency, backed by one ledger account for\nthat currency and one auto-provisioned IBAN. Further currency\naccounts of the same wallet appear in `account_ids`. Multiple wallets per currency are\nallowed; uniqueness is enforced by wallet name per customer (closed\nwallets are excluded from the constraint). The creation flow is\natomic: ledger account, database row, IBAN generation, and\nregistry linking all happen in one request. Default currency is EUR.\nSet `is_primary: true` to mark as primary wallet (cannot be closed).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateWalletRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Wallet created (includes provisioned IBAN)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "iban": {
                      "type": "string",
                      "example": "DE89PLAN00000000000001"
                    },
                    "currency": {
                      "$ref": "#/components/schemas/Currency"
                    },
                    "country": {
                      "type": "string",
                      "example": "DE"
                    },
                    "status": {
                      "type": "string",
                      "example": "active"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Customer not found (customer_id does not exist in finance_customer)"
          },
          "409": {
            "description": "Customer already has an active wallet with this name, or `customer_account_limit`: the customer has reached the bank's maximum of accounts (DEC-0042)"
          }
        }
      }
    },
    "/api/v1/wallets/{walletId}": {
      "get": {
        "operationId": "getWallet",
        "tags": ["Wallets"],
        "summary": "Get wallet by ID",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WalletId"
          }
        ],
        "responses": {
          "200": {
            "description": "Wallet details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Wallet"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "renameWallet",
        "tags": ["Wallets"],
        "summary": "Rename wallet",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WalletId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["name"],
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 50
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Wallet renamed"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/wallets/{walletId}/status-detail": {
      "get": {
        "operationId": "getWalletStatusDetail",
        "tags": ["Wallets"],
        "summary": "Why the account is in its state (freezes, stops, write-off)",
        "description": "Why the account is in its state, for the staff account page. Staff and\nservices only (a customer gets 403). `events`: the last 10 freezes,\nunfreezes, refused unfreezes, closures and write-offs of the account, its\nledger accounts and freezes of the whole customer, newest first, with the\nactor and the reason as recorded. `stops`: what keeps it frozen whatever\nan officer asks (customer suspended, a compliance hold, live freeze\ncases: counted for every role, listed by id for the mlro, the auditor,\nthe platform and services). `write_off`: a ledger account's write-off.\nAnother bank's account is not found.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WalletId"
          }
        ],
        "responses": {
          "200": {
            "description": "The account's status story",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountStatusDetail"
                }
              }
            }
          },
          "400": {
            "description": "Not an account id."
          },
          "403": {
            "description": "A customer, or a role without access to accounts."
          },
          "404": {
            "description": "No such account in this bank."
          }
        }
      }
    },
    "/api/v1/wallets/{walletId}/balances": {
      "get": {
        "operationId": "getWalletBalances",
        "tags": ["Wallets"],
        "summary": "Retrieve real-time wallet balances per currency",
        "description": "Returns available and pending balances for each currency held in the\nwallet, sourced directly from the ledger engine. Reflects all committed and\npending transfers in real time.\n\nPer currency: `available` (what the customer can spend: posted\ncredits less posted and pending debits), `pending` (outgoing\namounts reserved, pending debits) and `on_hold` (incoming direct\ndebit credits held until their holding period ends, pending credits;\nnot part of `available`). Minor units.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WalletId"
          }
        ],
        "responses": {
          "200": {
            "description": "Balances per currency",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "balances": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "object",
                        "properties": {
                          "available": {
                            "type": "integer",
                            "format": "int64"
                          },
                          "pending": {
                            "type": "integer",
                            "format": "int64"
                          },
                          "on_hold": {
                            "type": "integer",
                            "format": "int64"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/wallets/{walletId}/credit": {
      "post": {
        "operationId": "creditWallet",
        "tags": ["Wallets"],
        "summary": "Credit wallet (deposit funds)",
        "description": "Deposits funds into the wallet by creating a ledger credit\ntransfer. Requires an `Idempotency-Key` header to prevent duplicate\ndeposits on network retries. The operation is atomic and immediately\nreflected in the wallet balance.\n\nThe credit debits the shared suspense account, so only the platform\nmay call it: a service acting for nobody, or a super-admin in the\nplatform scope (DEC-0026). Tenant staff, and a service acting for a\ncell operator, get 403 `{\"error\":\"wallet_credit_platform_only\"}`;\nmanual deposits go through the four-eyes cash-deposit flow.\nCustomers get 403 `{\"error\":\"forbidden\"}`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WalletId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WalletCreditDebitRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Credit successful (ledger transfer created)"
          },
          "202": {
            "description": "Posted in the ledger, record pending (`\"record_status\":\"pending\"`).\nThe money moved; do not retry with a new key.\n"
          },
          "400": {
            "description": "Missing Idempotency-Key (customers and staff)"
          },
          "403": {
            "description": "Not a platform caller (`wallet_credit_platform_only`), or a customer (`forbidden`)"
          },
          "404": {
            "description": "The wallet's account is not the posting tenant's (`account_not_found`)"
          },
          "409": {
            "description": "Idempotency-Key reused for another request, or still in progress"
          },
          "503": {
            "description": "Temporary database failure, nothing posted; retry after `Retry-After`"
          }
        }
      }
    },
    "/api/v1/wallets/{walletId}/debit": {
      "post": {
        "operationId": "debitWallet",
        "tags": ["Wallets"],
        "summary": "Debit wallet (withdrawal with limit enforcement)",
        "description": "Withdraws funds from the wallet. Enforces three tiers of spending\nlimits: single-transaction, daily aggregate, and monthly aggregate.\nReturns `422 Unprocessable Entity` if the debit would exceed any\nconfigured limit or if insufficient funds are available. Requires an\n`Idempotency-Key` header to prevent duplicate withdrawals.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WalletId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WalletCreditDebitRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Debit successful"
          },
          "202": {
            "description": "Posted in the ledger, record pending (`\"record_status\":\"pending\"`).\nThe money moved; do not retry with a new key.\n"
          },
          "400": {
            "description": "Missing Idempotency-Key (customers and staff)"
          },
          "403": {
            "description": "Customer token (`forbidden`)"
          },
          "404": {
            "description": "The wallet's account is not the posting tenant's (`account_not_found`)"
          },
          "409": {
            "description": "Idempotency-Key reused for another request, or still in progress"
          },
          "422": {
            "description": "Insufficient funds or spending limit exceeded"
          },
          "503": {
            "description": "Temporary database failure, nothing posted; retry after `Retry-After`"
          }
        }
      }
    },
    "/api/v1/wallets/{walletId}/freeze": {
      "post": {
        "operationId": "freezeWallet",
        "tags": ["Wallets"],
        "summary": "Freeze wallet",
        "description": "Never gated. Staff send a reason category and a reason of at least 10\ncharacters (400 `reason_required` otherwise): the officer of the\nsession and the reason are written to the freeze's audit rows.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WalletId"
          }
        ],
        "requestBody": {
          "description": "Staff only (a customer or a service sends no body).",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OfficerReason"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Wallet frozen",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WalletStatusReply"
                }
              }
            }
          },
          "400": {
            "description": "`reason_required` (staff)"
          }
        }
      }
    },
    "/api/v1/wallets/{walletId}/unfreeze": {
      "post": {
        "operationId": "unfreezeWallet",
        "tags": ["Wallets"],
        "summary": "Unfreeze wallet",
        "description": "A customer lifts only their own freeze (SCA). Staff: the request is\nrecorded and a second officer decides (202, migration 268); the\nunfreeze then runs with the requester as actor, and a live compliance\nstop keeps it from running (409 `compliance_hold`, the request stays\npending).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WalletId"
          }
        ],
        "requestBody": {
          "description": "Staff only (a customer or a service sends no body).",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OfficerReason"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Wallet unfrozen (customer or service)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WalletStatusReply"
                }
              }
            }
          },
          "202": {
            "description": "Staff request recorded; a second officer decides (`/api/v1/ops-approvals`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpsApprovalPending"
                }
              }
            }
          },
          "400": {
            "description": "`reason_required`: a reason category and a reason of at least 10 characters"
          },
          "403": {
            "description": "`forbidden_role` (only the platform scope or a cell `bank_admin` asks), `person_required`"
          },
          "409": {
            "description": "`approval_pending` (a request already waits on this account), `not_frozen`, `already_closed`, `invalid_status`"
          },
          "422": {
            "description": "`balance_not_zero`, `pending_transfers`, `primary_account`"
          }
        }
      }
    },
    "/api/v1/wallets/{walletId}/close": {
      "post": {
        "operationId": "closeWallet",
        "tags": ["Wallets"],
        "summary": "Close wallet (terminal state)",
        "description": "Closes a wallet permanently. Primary wallets (`is_primary: true`)\ncannot be closed: the call returns 400 `{\"error\":\"Invalid input\"}`.\nThis is enforced both at the application level and by a database\ntrigger. Staff: the request is recorded and a second officer decides\n(202, migration 268); every currency account of the wallet must have\na zero balance and nothing pending, checked when asked and again\nwhen approved (422 `balance_not_zero`, `pending_transfers`,\n`primary_account`).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WalletId"
          }
        ],
        "requestBody": {
          "description": "Staff only (a customer or a service sends no body).",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OfficerReason"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Wallet closed (customer or service)"
          },
          "202": {
            "description": "Staff request recorded; a second officer decides (`/api/v1/ops-approvals`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpsApprovalPending"
                }
              }
            }
          },
          "400": {
            "description": "Primary wallet cannot be closed (`{\"error\":\"Invalid input\"}`), or malformed id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Wallet not found"
          },
          "409": {
            "description": "Already closed"
          }
        }
      }
    },
    "/api/v1/wallets/{walletId}/limits": {
      "post": {
        "operationId": "updateWalletSpendingLimits",
        "tags": ["Wallets"],
        "summary": "Set wallet spending limits",
        "description": "Minor units of the wallet's currency, integers of at least 0. An\nabsent member keeps its limit; a member that is not such an integer\n(1.50, a string, a negative number) is 400 `invalid_amount` and\nnothing is saved.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WalletId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "daily_spending_limit": {
                    "type": "integer",
                    "format": "int64"
                  },
                  "monthly_spending_limit": {
                    "type": "integer",
                    "format": "int64"
                  },
                  "single_transaction_limit": {
                    "type": "integer",
                    "format": "int64"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Limits updated"
          },
          "400": {
            "description": "`invalid_amount`, or no limit given"
          }
        }
      }
    },
    "/api/v1/transfers": {
      "get": {
        "operationId": "listTransfers",
        "tags": ["Transfers"],
        "summary": "List transfer records with bi-temporal metadata",
        "description": "Returns paginated transfer metadata. The `description` field is\nlocalised based on the `Accept-Language` request header for\nsystem-generated transfer types (deposit, withdrawal, fee, etc.).\nCaller-supplied free-text descriptions are returned unchanged.\nSupported languages: `en` (default), `ar`, `de`, `fr`, `es`, `tr`, `ru`.\n\n**Deprecated for customer callers (DEC-0029).** Offset paging with a\ntotal count on every call. Customer JWT callers use\n`GET /api/v1/accounts/{accountId}/transactions` (keyset cursor)\ninstead. Sunset for customer callers: 2026-12-31. Staff and service\ncallers are not affected.\n\nEvery filter runs over all matching rows and `total` counts them\n(Core-Bank audit 2026-10-06). Text values are percent-decoded and\nmatched case-insensitively anywhere (`%` and `_` are literal).\nA bad day or currency is 400 `Invalid filter`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptLanguage"
          },
          {
            "in": "query",
            "name": "account_id",
            "description": "A ledger account (hex), debit or credit side.",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "description": "An exact status (pending, completed, rejected, cancelled,\nvoided), or one of three groups (Core-Bank UX review\n2026-10-07): `held` (pending_review or held, or pending on a\nholding period), `failed` (failed or rejected, an\nR-transaction REJECT, or a provider `failed` step) and\n`returned` (returned, an R-transaction RETURN, REFUND or\nREVERSAL, a returned holding period, or a provider `returned`\nstep).\n",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "sort",
            "description": "`booked` (default: booking date, then creation), `date` (creation time), `amount` (absolute amount) or `status`. Anything else is 400.",
            "schema": {
              "type": "string",
              "enum": ["booked", "date", "amount", "status"]
            }
          },
          {
            "in": "query",
            "name": "dir",
            "description": "`desc` (default) or `asc`. Anything else is 400.",
            "schema": {
              "type": "string",
              "enum": ["asc", "desc"]
            }
          },
          {
            "in": "query",
            "name": "event_type",
            "description": "One event type, or several separated by commas.",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "currency",
            "description": "ISO 4217 code.",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "search",
            "description": "Free text over reference, description, ids and both party names.",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "from_name",
            "description": "Text in the paying party's name.",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "to_name",
            "description": "Text in the receiving party's name.",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "reference",
            "description": "Text in the reference or description.",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "amount_min",
            "description": "Minor units of the transfer's own currency, inclusive (absolute amount). Not a whole number >= 0 is 400.",
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 0
            }
          },
          {
            "in": "query",
            "name": "amount_max",
            "description": "Minor units, inclusive (absolute amount). Not a whole number >= 0 is 400.",
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 0
            }
          },
          {
            "in": "query",
            "name": "date_from",
            "description": "First creation day (YYYY-MM-DD, UTC), inclusive. Not a calendar day (2031-02-30) is 400.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "in": "query",
            "name": "date_to",
            "description": "Last creation day (YYYY-MM-DD, UTC), inclusive.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "in": "query",
            "name": "wallet_id",
            "description": "A customer account: transfers of its ledger accounts only; none when it has no ledger account.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "description": "At most 500.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "offset",
            "description": "Rows to skip; not a number or above 1,000,000 is 400.",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 1000000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Transfer list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "transfers": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Transfer"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createTransfer",
        "tags": ["Transfers"],
        "summary": "Execute ledger transfer with regulatory checks",
        "description": "Atomically creates a transfer in the ledger, persists bi-temporal metadata\n(value date, booking date) to the database, and writes an audit event\nto the hash-chained audit trail.\nThe following checks are enforced before ledger commitment:\n\n1. **Tenant feature flag** - verifies the tenant has transfer capability enabled\n2. **Transaction limits** - evaluates hierarchical limits (account > customer > tenant)\n3. **Sufficient funds** - the ledger engine rejects overdrafts at the ledger level\n4. **Strong customer authentication** - see below\n5. **Idempotency** - `Idempotency-Key` header prevents duplicate execution\n\nStrong customer authentication (0.34.0, no amount threshold). Service\nand staff callers act for the institution and do not send\n`X-SCA-Token`. A customer caller passes, in this order:\n\n1. `X-SCA-Token` is an SCA authentication code from identity-api\n   (JWS RS256, `typ` `sca+jwt`, `aud` `fernel-sca`, valid at most\n   120 s): its signature, expiry, tenant, login (`sub`), customer,\n   `kind` `payment` and `intent` must match this request, and its\n   `jti` is spent once. The same code passes again only with the\n   same `Idempotency-Key` and intent (the retry of this write;\n   the low-value counters are reset by the first use only). A\n   customer names no `to_account_id` next to `destination_*` (400\n   `to_account_id_not_allowed`): the credited account is always\n   the creditor the intent names.\n2. Exemptions set per tenant:\n   both accounts the caller's own (internal rail); low value (at most\n   EUR 30, and since the last SCA at most EUR 100 and 5 payments\n   including this one, EUR equivalent at the static reference rate).\n3. The tenant's mode: `off` accepts the caller's own access token\n   as `X-SCA-Token` (another login's token is refused); `optional`\n   and `required` create a challenge on the customer's bound phone\n   and answer 403 `sca_required` with it. The client waits for the\n   approval, exchanges it at identity-api for the SCA code and sends\n   the same request again (same body and `Idempotency-Key`) with\n   the code. Without a usable phone, `optional` keeps the `off` rule\n   and `required` answers 403 `sca_setup_required`. `optional` is\n   `required` from the tenant's `grace_until`. In both modes, a\n   locked phone or one removed in the last 24 h answers 403\n   `sca_device_locked` (`reason` `locked` or `recently_removed`,\n   `until`), and a login that once had an active phone and has none\n   now answers 403 `sca_setup_required`: never the `off` rule.\n\nThe intent is the lower-case hex SHA-256 of these lines joined by\n`\\n`, no trailing newline (SPEC-sca-canonical-v1):\n`FERNEL-PAY-INTENT-V1`, `tenant:<uuid>`, `customer:<uuid>`,\n`debtor:<from_account_id, 32 hex>`, `amount:<minor units>`,\n`currency:<ISO 4217>`, `creditor:<destination_iban without spaces,\nor acct:<to_account_id, 32 hex> on the internal rail, or\nacctno:<destination_account_number>, then @<destination_bic> when\none is sent and ;routing:<destination_routing_number digits> when\none is sent; at least one of the two>` (SPEC-sca-canonical-v1\n1.3.0),\n`rail:<internal|sepa_sct|sepa_inst|sic|sic_ip|swift|fps>`. UUIDs and\nhex lower-case, IBAN, BIC and currency upper-case. Where the intent\nis needed (an SCA code, or a challenge in `optional` / `required`), a\ncreditor without that form (an IBAN without country and check\ndigits, an account number with other than letters and digits, a BIC\nthat is not 8 or 11 characters, a routing number that is not 6 to 9\ndigits once spaces and dashes are removed) is 400\n`{\"error\":\"invalid_creditor\"}`.\n\nFees: `event_type` in canonical (`transfer_sepa_sct`) or short\n(`sepa_sct`) form selects the same tenant fee schedule as\n`POST /api/v1/fees/calculate`. Our fee is always the sender's,\ncharged on top of `amount`: the account is debited `amount` + fee\nand `amount` is sent (the preview's `total_debit` and\n`recipient_gets`). `charge_bearer` per rail (DEC-0038, 0.31.0):\nSEPA SCT, SCT Inst, SIC and SIC IP store and send `slev` whatever is\nsent (`our` and `sha` from older clients included); `ben` is 422\n`charge_bearer_not_allowed` and nothing is posted or parked. SWIFT\nkeeps `sha` (default), `our` and `ben` (MT103 71A / pacs.008\nChrgBr); only SWIFT `ben` takes the fee off the amount sent. SWIFT\n`our` stays OUR only where the fee preview offers it (an OUR price\nis configured and the beneficiary bank, by `destination_bic` else\n`destination_bank_country`, is outside the EEA); otherwise it is\nstored and sent as `sha` (71A SHA, ChrgBr SHAR). No tenant has an\nOUR price today, so SWIFT `our` is `sha`.\nInternal and FPS transfers carry no bearer (`ben` is 422 there too).\n`expected_total_debit` (optional, minor units): the total the client\nshowed; a different total (the fee schedule changed since the\npreview) is 409 `{\"error\":\"fee_changed\",\"total_debit\":<new>}` and\nnothing is posted or parked.\nA transfer over a limit (202, approval) stores the fee and bearer\ncalculated here and executes with exactly those, also when the fee\nschedule changed in between.\n\n`beneficiary_id` (optional): must be the caller's own active payee in\nthe tenant (404 `beneficiary_not_found` otherwise) and match the\ndestination: same IBAN (or account and routing number) and, when\n`destination_name` is sent, the same name (400\n`beneficiary_mismatch`). It is then used for screening and stored on\nthe transfer. For a customer JWT, fees and limits use the JWT\ncustomer, not a body `customer_id`.\n\nDirect debit credits (`event_type` `sepa_sdd`, BR-EF-011): for a bank\nwith the ledger hold switched on (HoldingPeriods), the credit of an\nincoming direct debit (a customer account credited from outside the\ncustomer accounts) with a holding period above 0 days is posted as a\npending ledger transfer: the answer has `\"status\":\"pending\"`,\n`\"settlement_status\":\"SETTLED_PENDING\"` and `held_until` (UTC), the\ncustomer's available balance excludes the amount until the\nsettlement scheduler releases it. When the switch, the customer or\nthe holding period cannot be read, the credit is refused with 503\n`holding_period_unavailable` (nothing posted), never credited without\nits hold.\n\nSWIFT (DEC-0030): the transfer stores `uetr` (UUID v4, the same on a\nretry with the same key), `charge_bearer`, `intermediary_bic`,\n`purpose_code`, `remittance_info`, `beneficiary_bic`,\n`beneficiary_bank_name` and `beneficiary_bank_country` in its\nmetadata; the answer carries `uetr` (and `charge_bearer`).\n\nA payment to another bank (any `destination_*` field) names a valid\ndestination account: an IBAN with its check digits (ISO 13616) or an\naccount number; else 400 `{\"error\":\"payee_required\"}` (with\n`\"field\":\"destination_iban\"` or `\"destination_account_number\"` for a\nmalformed one), nothing posted or parked (2026-10-07).\n\nOver a limit of the account or customer, the transfer is parked for a\nsecond officer (202, `pending_review`) only after the checks a direct\ntransfer passes: AccountGuard and the transfer-path screening refuse\nor hold it exactly as a direct one (422). The approval stores the\npayee, the rail, `reference`, `counterparty_name`, `beneficiary_id`,\nthe SWIFT fields, `destination_routing_number`, the bank's name and\ncountry and `sepa_end_to_end_id` (migrations 293, 301), and the\nscreening it passed (`screening_verdict`, `screening_result_id`).\nThe execution carries them onto the record. On every transfer,\nparked or not, `reference` (255), `sepa_end_to_end_id` (35),\n`destination_routing_number`, `destination_bank_name` and\n`destination_bank_country` (255) must be within those limits and\nUTF-8, else 400 `{\"error\":\"invalid_payment_field\",\"field\":...}`\nbefore anything moves.\n\nEach new transfer records its timeline steps (created, checked,\nsent for a payment network, arrived except for SWIFT); see\n`GET /api/v1/transfers/{transferId}/timeline`.\n\nOn success, a webhook event is emitted for downstream notification.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "name": "X-Tenant-ID",
            "in": "header",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-SCA-Token",
            "in": "header",
            "schema": {
              "type": "string"
            },
            "description": "Customer callers, unless exempt. The SCA authentication code from identity-api; while the tenant's mode allows it (`off`, or `optional` without a bound phone), the caller's own access token. Service and staff callers do not send it."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTransferRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Transfer created. A retry with the same Idempotency-Key and the same body returns the stored response (keys are per tenant and caller, kept in Postgres)."
          },
          "202": {
            "description": "Accepted for approval or holding (limit exceeded or held), or posted in the ledger with `\"record_status\":\"pending\"`: the transfer moved, its record is written by operations (do not send it again)."
          },
          "400": {
            "description": "Bad request, including `{\"error\":\"invalid_charge_bearer\"}`, `{\"error\":\"invalid_intermediary_bic\"}`, `{\"error\":\"invalid_destination_bic\"}`, `{\"error\":\"invalid_purpose_code\"}`, `{\"error\":\"invalid_remittance_info\"}` (SWIFT), `{\"error\":\"invalid_beneficiary_id\"}`, `{\"error\":\"beneficiary_mismatch\"}`, `{\"error\":\"counterparty_name_too_long\",\"max_length\":140}`, `{\"error\":\"counterparty_name_invalid\"}`, `{\"error\":\"invalid_expected_total_debit\"}` (not an integer), `{\"error\":\"to_account_id_not_allowed\"}` (0.34.0: a customer JWT named `to_account_id` next to a `destination_*` field; the institution's clearing account is credited, so the account credited is the creditor the customer approved), `{\"error\":\"payee_required\"}` (2026-10-07: a payment to another bank without a valid destination account; `\"field\"` names a malformed `destination_iban` or `destination_account_number`), `{\"error\":\"invalid_payment_field\",\"field\":\"...\"}` (a payment field over its limit or not UTF-8, on every transfer), `{\"error\":\"invalid_creditor\"}` (the destination cannot be put in the SCA intent: an IBAN, account number or BIC with characters other than letters and digits), a missing Idempotency-Key, and an amount that is not an integer in minor units (`1.50`, `1e6`); `Unsupported currency`: a currency or ledger without an ISO code (the fee, the limits and the records use the ledger's code; never a default currency).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCA (0.34.0): `{\"error\":\"SCA required\",\"code\":\"sca_required\",\"challenge\":{...}}` (approve on the bound phone, then send again with the SCA code); `{\"error\":\"SCA required\",\"code\":\"sca_setup_required\",\"active_from\":...}` (mode `required`, no phone that may approve payments yet; also mode `optional` when the login once had an active phone); `{\"error\":\"SCA required\",\"code\":\"sca_device_locked\",\"reason\":\"locked\"|\"recently_removed\",\"until\":...}` (the phone is locked, or was removed in the last 24 h; modes `optional` and `required`); `{\"error\":\"SCA required\",\"reason\":...}` (no `X-SCA-Token` where the access token is still accepted); `{\"error\":\"Invalid SCA token\",\"code\":...}` with `code` `sca_token_invalid`, `sca_token_expired`, `sca_token_used`, `sca_intent_mismatch` (amount or payee differ from the approved ones), `sca_wrong_kind` or `sca_wrong_customer`. Tenant transfer limits are EUR cents; the amount is compared as its EUR equivalent (currency exponent, static reference rate). `{\"error\":\"counterparty_name_not_allowed\"}`: a customer JWT sent `counterparty_name` without a `beneficiary_id`. Staff callers (DEC-0043): `{\"error\":{\"code\":\"forbidden_role\",...}}` for every role but `recovery_manager` and the platform `super_admin`; those post only the recovery of a written-off account, else `{\"error\":\"staff_recovery_only\"}` (an `event_type` other than `woff_recovery`) `{\"error\":\"recovery_account_not_written_off\"}` (the credited account is not a written-off account of the tenant) or `{\"error\":\"recovery_source_not_allowed\"}` (the debit account is not another account of the written-off account's customer). Nothing was posted.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ScaError"
                    },
                    {
                      "$ref": "#/components/schemas/Error"
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "`{\"error\":\"beneficiary_not_found\"}`, or `{\"error\":\"account_not_found\"}`: a leg is not an account of the posting tenant (nor a platform account), or the debit account is not the customer caller's. Foreign and unknown ids get the same answer.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "`{\"error\":\"idempotency_key_reused\"}` (the key was used for another body), the same request still in progress, `{\"error\":\"fee_changed\",\"total_debit\":10200}` (0.31.0): `expected_total_debit` differs from the total this transfer debits; nothing was posted or parked, preview again and confirm the new total, or `{\"error\":\"sca_busy\",\"retry_after\":12}` (0.34.0): another approval of this customer is pending on the phone."
          },
          "422": {
            "description": "Refused; nothing was posted. Specific for every caller (the customer can act on them): `Transfer failed - insufficient funds or currency mismatch`, `{\"error\":\"Fee exceeds transfer amount\"}` (SWIFT `ben`), `{\"error\":\"charge_bearer_not_allowed\"}` (`ben` on a rail other than SWIFT, 0.31.0), and a transaction limit of the customer (`daily_used`, `daily_limit`, ...). Compliance and risk refusals: staff and service callers get the specific body (`beneficiary_screening_hold`, `screening_subject_required`, `Transaction Failed: Account status restricted` with `code`, `Tenant single transfer limit exceeded`, `Tenant daily transfer limit exceeded`, `Tenant monthly transfer limit exceeded` (only once the platform enforces the bank's ceilings, `ceilings_enforced`), `fee_tier_not_matched` (no tier of the fee schedule of the bank covers the amount: refused, never priced at 0, not retryable), `fee_currency_not_priced` (the bank prices this payment type, but not in this currency: refused, never free), `currency_required`, `deposit_cap_exceeded`, `intake_blocked`); a customer JWT gets one neutral body for all of them, `{\"error\":\"payment_not_possible\",\"message\":\"The payment could not be processed.\"}`, and no reason (no tipping-off, Ley 10/2010 art. 24).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "`{\"error\":\"sca_rate_limited\"}` (0.34.0): too many approvals asked for this customer; nothing was posted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "`{\"error\":\"idempotency_store_unavailable\"}`: nothing was posted. A check that could not run (`beneficiary_screening_unavailable`, `screening_not_configured`, `tenant_check_unavailable`, `session_check_unavailable`, `limit_check_unavailable`, `account_guard_unavailable`, `fee_calculation_unavailable`, `fee_account_unavailable`, `deposit_cap_unavailable`, `fx_rate_unavailable`, `holding_period_unavailable` to staff and service callers): a customer JWT gets one body for all of them, `{\"error\":\"try_again_later\",\"message\":\"The payment cannot be processed right now. Please try again later.\"}` with `Retry-After: 1`, also when a transient database failure made the request retryable. Nothing was posted; safe to retry with the same Idempotency-Key. `{\"error\":\"sca_unavailable\"}` with `Retry-After: 5` (0.34.0, every caller): the SCA challenge or the tenant's SCA policy could not be reached; nothing was posted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/transfers/{transferId}": {
      "get": {
        "operationId": "getTransfer",
        "tags": ["Transfers"],
        "summary": "Get transfer by ID with full detail",
        "description": "Returns comprehensive transfer metadata including bi-temporal dates,\nfee breakdown, FX conversion details (when applicable), SEPA E2E ID,\nsender/recipient IBANs, tenant context, and R-transaction status\n(BR-EF-011). The response includes all fields needed for both customer\nand admin portal transaction detail views.\n\nConditional blocks:\n- **FX fields** \u2014 only present when the transfer involves a currency conversion\n- **R-transaction fields** \u2014 only present for SEPA returns, refunds, and reversals\n- **metadata** \u2014 JSONB object with type-specific details (fx_pair, tier, override, leg)\n\nThe `description` field is localised based on the `Accept-Language` header\nfor system-generated transfer types. Supported: `en` (default), `ar`, `de`,\n`fr`, `es`, `tr`, `ru`. The response always includes a `Content-Language` header.\n\nSupport roles (ARCH-029a \u00a712) read a transfer only with `case_id`, a\ncase they can see, and only its linked transfer or one of the 20\nnewest transfers of its customer (400 `invalid_id` without a case,\n404 `not_found` otherwise).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TransferId"
          },
          {
            "$ref": "#/components/parameters/AcceptLanguage"
          },
          {
            "$ref": "#/components/parameters/SupportTransferCase"
          }
        ],
        "responses": {
          "200": {
            "description": "Transfer details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransferDetail"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/transfers/{transferId}/cancel": {
      "post": {
        "operationId": "cancelTransfer",
        "tags": ["Transfers"],
        "summary": "Cancel a pending transfer (officer, audited)",
        "description": "Cancels a transfer whose ledger hold was never posted. Only `pending`\nis cancellable: the two-phase hold is voided in the ledger, the\ntransfer is set to `cancelled`, and a hash-chained audit row\n(`transfer.cancel`, event 2400) records the officer of the session,\nthe reason category and the reason. `completed` and `failed` stand\n(a return or reversal is an R-transaction), `cancelled` and `voided`\nhave ended, and `pending_review` is an approval (reject it on the\napprovals queue): all are 409 `transfer_not_cancellable` with the\nstatus. Only a payment transfer is cancellable (transfer_internal,\ntransfer_sepa_sct, transfer_swift, withdrawal; not an instant payment): a\npending card authorisation, capture or other hold is 409\n`transfer_not_cancellable` with `event_type`. The ledger void runs last: when it fails nothing is written\n(409 `transfer_void_failed`; 503 `ledger_unavailable` without a\nledger). Staff: the platform scope or a cell `mlro`; customers 403.\nA direct debit credit held until its holding period ends\n(HoldingPeriods, ledger hold) cannot be cancelled: 409\n`held_direct_debit` (the settlement scheduler releases it, a return\nvoids it); once released, 409 `already_released_direct_debit`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TransferId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["reason_category", "reason"],
                "properties": {
                  "reason_category": {
                    "type": "string",
                    "pattern": "^[a-z_]{2,40}$",
                    "description": "e.g. customer_request, duplicate, fraud_suspected, operational_error, other."
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 10,
                    "maxLength": 1000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Transfer cancelled and the hold voided",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": ["cancelled"]
                    },
                    "transfer_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`reason_required`: a reason category and a reason of at least 10 characters"
          },
          "403": {
            "description": "`forbidden_role`, `person_required` (no officer), or a customer"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`transfer_not_cancellable` (with `status`, or `event_type` for a card payment or other hold), `transfer_void_failed`, `held_direct_debit` (a direct debit credit on hold) or `already_released_direct_debit` (released at the end of its holding period: undo it with a compensating transfer); nothing changed"
          },
          "503": {
            "description": "`ledger_unavailable`: nothing changed"
          }
        }
      }
    },
    "/api/v1/transfers/{transferId}/timeline": {
      "get": {
        "operationId": "getTransferTimeline",
        "tags": ["Transfers"],
        "summary": "Status timeline of a transfer (DEC-0030)",
        "description": "Where a payment is, as plain steps: created, checked, [approval],\nsent, in the SWIFT network, arrived; received, [on hold], credited\nfor incoming money; converted, settled, authorized, reversed,\nrefunded for FX, fees and cards. A returned, failed or cancelled\ntransfer shows the path so far, then one `returned`, `failed` or\n`cancelled` step in state `failed`.\n\nBuilt from the transfer's recorded events (`finance_transfer_event`)\nand its own columns (created, booking, status, settlement and\nR-transaction columns, the approval and card authorisation rows).\nTransfers from before the events existed are derived from the\ncolumns and give the same JSON.\n\nSWIFT: `status` is `completed` once our books are debited and the\npayment is sent; `arrived` is done only after a provider reported\narrival (gpi ACCC, `POST /transfers/{id}/events`). Until then\n`in_network` is the current step.\n\n`expected_by` (while in progress): SEPA Instant and SIC IP sent + 10\ns; SEPA SCT the next TARGET business day 16:00 UTC; SIC the same\nSwiss business day if sent before 16:15 Europe/Zurich, else the\nnext, at 16:15 Zurich; SWIFT two TARGET business days, 16:00 UTC\n(clients show \"1-3 business days\"); incoming on hold: the end of the\nhold. None for internal transfers.\n\nScope: as `GET /transfers/{transferId}`. A customer JWT reads only a\ntransfer with a leg on one of its own accounts (another customer's\nor unknown id: 404 `{\"error\":\"not_found\"}`); `direction` is then the\ncustomer's. Staff read in their tenant; support roles only with\n`case_id`, as `GET /transfers/{transferId}`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TransferId"
          },
          {
            "$ref": "#/components/parameters/SupportTransferCase"
          }
        ],
        "responses": {
          "200": {
            "description": "The timeline",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransferTimeline"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_id`: not a hex transfer id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemError"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemError"
                }
              }
            }
          },
          "503": {
            "description": "`timeline_unavailable`, with Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/transfers/{transferId}/swift": {
      "get": {
        "operationId": "getTransferSwift",
        "tags": ["Transfers"],
        "summary": "SWIFT details of an outgoing SWIFT transfer (DEC-0030)",
        "description": "UETR, charges, intermediary, beneficiary bank, the latest gpi status\nand the MT103 fields of the payment. Tags without data are left\nout, never invented (no BIC of ours unless the account has one).\n\n`?format=mt103`: `text/plain` download (`mt103-<ref>.txt`), block 4\nonly, one `:tag:value` line per field, CRLF line ends, SWIFT X\ncharacter set. `?format=pacs008`: `application/xml` download\n(`pacs008-<ref>.xml`), pacs.008.001.08. A transfer from before\nDEC-0030 has no stored charge bearer: JSON and MT103 leave 71A out,\nthe XML (where ChrgBr is mandatory) says SHAR, the SWIFT default.\n\nScope: as `GET /transfers/{transferId}`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TransferId"
          },
          {
            "name": "format",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["json", "mt103", "pacs008"],
              "default": "json"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "SWIFT details, or the requested download",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransferSwift"
                }
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "application/xml": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_id` or `invalid_format`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemError"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`, or `not_swift` (the rail is not SWIFT)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/transfers/{transferId}/events": {
      "post": {
        "operationId": "postTransferEvent",
        "tags": ["Transfers"],
        "summary": "Report a provider status of a transfer (service key only, DEC-0030)",
        "description": "The provider (today the mock and the demo script) reports where a\npayment is: `in_network` (SWIFT only, gpi ACSP), `arrived` (gpi\nACCC), `returned` or `failed` (reason code). Recording moves no\nmoney; a return or failure in the ledger is the R-transaction\nroute's job.\n\nService key only: customer JWTs (403 `{\"error\":\"forbidden\"}` from\nthe scope check), staff sessions and service calls acting for an\noperator (403 `forbidden`) are refused.\n\nIdempotent on (transfer, step, code): the same report again answers\n200 with `\"recorded\":false` and writes nothing. `Idempotency-Key` is\naccepted and not needed. `occurred_at` (RFC 3339) defaults to now; a\ntime more than 5 minutes ahead is 400 `invalid_occurred_at`.\n",
        "security": [
          {
            "ServiceKeyAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TransferId"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TransferEventRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Recorded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransferEventResult"
                }
              }
            }
          },
          "200": {
            "description": "Already recorded (replay), nothing written",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransferEventResult"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_id`, `invalid_body`, `invalid_step`, `invalid_code`, `invalid_occurred_at`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemError"
                }
              }
            }
          },
          "403": {
            "description": "`forbidden`: not a service key call"
          },
          "404": {
            "description": "`not_found`: no such transfer for the caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemError"
                }
              }
            }
          },
          "409": {
            "description": "`step_not_applicable`: `in_network` on a rail other than SWIFT, or any step on a transfer without a payment network rail",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/transfers/{transferId}/confirmation": {
      "get": {
        "operationId": "getTransferConfirmation",
        "tags": ["Documents", "Transfers"],
        "summary": "Transfer confirmation (PDF)",
        "description": "Payment confirmation: tenant brand and legal name, amount and\nstatus, a \"Progress\" section, payer (name, IBAN), payee (name, IBAN\nor account, BIC, bank), reference, created / booked / value dates,\nfee, FX (rate and amounts), and for SWIFT the UETR, charges,\nintermediary and the MT103 fields that have data (no invented BIC),\nthen the transfer id, the generation time and the legal footer.\n\nThe progress lists the steps of `GET /transfers/{id}/timeline` (same\nderivation, same step labels as the clients, in the document's\nlocale): the local time (`tz_offset_minutes`) of each step reached,\n\"In progress\" for the current one and \"Expected by <date>\" for an\nupcoming arrival; a returned or failed step shows its reason code. It\nis left out when the timeline cannot be read (before migration 223).\nThe MT103 lines are those of `GET /transfers/{id}/swift` (the same\nbuilder), and the SWIFT section reads the same record. A customer JWT\nreaches its own transfers only (as `GET /transfers/{id}`); the\ndirection of the steps is the customer's. File name\n`transfer-<date>-<reference>.pdf`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TransferId"
          },
          {
            "$ref": "#/components/parameters/DocumentLocale"
          },
          {
            "$ref": "#/components/parameters/HistoryTzOffset"
          }
        ],
        "responses": {
          "200": {
            "description": "The confirmation",
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/DocumentBadRequest"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/DocumentNotFound"
          },
          "409": {
            "description": "`not_confirmable`: the transfer failed or was cancelled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentError"
                },
                "example": {
                  "error": {
                    "code": "not_confirmable",
                    "message": "No confirmation for a failed or cancelled transfer"
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/DocumentBusy"
          },
          "500": {
            "$ref": "#/components/responses/DocumentFailed"
          },
          "503": {
            "$ref": "#/components/responses/DocumentUnavailable"
          }
        }
      }
    },
    "/api/v1/transfers/by-correlation/{correlationId}": {
      "get": {
        "operationId": "getTransferByCorrelation",
        "tags": ["Transfers"],
        "summary": "Look up transfer by correlation ID",
        "description": "Retrieves all transfer legs sharing a correlation ID. Useful for\nmatching inbound SEPA messages or webhook callbacks to an existing\ntransfer record without knowing the internal transfer ID.\nThe `description` field is localised per `Accept-Language`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "correlationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "External correlation identifier"
          },
          {
            "$ref": "#/components/parameters/AcceptLanguage"
          }
        ],
        "responses": {
          "200": {
            "description": "Transfer details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransferDetail"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/transfers/export": {
      "get": {
        "operationId": "exportTransfers",
        "tags": ["Transfers"],
        "summary": "Export one bank's transfers",
        "description": "Up to 10,000 transfers of the request's tenant, newest booking first.\nThe export always covers one bank: the session's tenant inside a\ncell, `X-Tenant-ID` for a super-admin in the platform scope or a\nservice key. A request without a tenant is refused (403\n`tenant_required`) instead of exporting every tenant through the\nplatform scope; the statement names the tenant itself besides RLS.\n\nKAM scope (F-07): a staff role that sees only its assigned customers\n(every role but super_admin, bank_admin, mlro and auditor) gets the\ntransfers of the customers `finance_kam_assignment` assigns to it,\nnone without an assignment. The customer list is the server's: there\nis no `customer_ids` parameter (400 `invalid_customer_scope`).\n\nFilters: `date_from` and `date_to` (`YYYY-MM-DD`), `status`, and\n`customer_id` (one UUID, within the KAM scope). An unusable\n`customer_id` is refused (400 `invalid_customer_scope`), never\ndropped. Report jobs export through\n`GET /api/v1/report-jobs/{jobId}/transfers`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TenantScope"
          },
          {
            "name": "date_from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "date_to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "customer_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The tenant's transfers",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "transfers": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`{\"error\":\"invalid_customer_scope\"}`: `customer_id` is not a UUID, or `customer_ids` is sent; `{\"error\":\"invalid_date\"}`: a date that is not a real calendar day (YYYY-MM-DD), or from after to"
          },
          "403": {
            "description": "`{\"error\":\"tenant_required\"}`: the request has no tenant (a service key naming none, a super-admin without X-Tenant-ID)"
          }
        }
      }
    },
    "/api/v1/transfers/split": {
      "post": {
        "operationId": "splitTransfer",
        "tags": ["Transfers"],
        "summary": "Execute atomic multi-leg split transfer",
        "description": "Creates up to 16 transfer legs as a single atomic batch using linked\ntransfer semantics. Either all legs succeed or none are committed\n(all-or-nothing). Common use cases include fee splitting (platform fee +\nmerchant payout), multi-beneficiary distributions, and internal treasury\nmovements. Each leg is independently validated for sufficient funds and\nlimit compliance before the batch is submitted to the ledger.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["legs"],
                "properties": {
                  "legs": {
                    "type": "array",
                    "maxItems": 16,
                    "items": {
                      "$ref": "#/components/schemas/CreateTransferRequest"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "403": {
            "description": "`{\"error\":\"Tenant suspended\"}`"
          },
          "404": {
            "description": "`{\"error\":\"account_not_found\"}`: a leg is not an account of the posting tenant, or a platform account debited by a non-platform caller. Foreign and unknown ids get the same answer (DEC-0026)."
          },
          "422": {
            "description": "`fee_tier_not_matched`: no tier of the fee schedule of the bank covers the amount; nothing was posted, not retryable. Staff and service callers get the code; a customer JWT gets `{\"error\":\"payment_not_possible\",\"message\":\"The payment could not be processed.\"}`. Also `fee_currency_not_priced` (the bank prices this payment type, but not in this currency: refused, never free), `currency_required`; the bank's and the account's limits on the split total, as on POST /api/v1/transfers (`Tenant single transfer limit exceeded`, the bank's daily and monthly ceilings once enforced: the specific body to staff and services, `{\"error\":\"payment_not_possible\",\"message\":\"The payment could not be processed.\"}` to a customer; an exceeded limit of the account: `{\"error\":\"Single|Daily|Monthly transaction limit exceeded\",\"daily_used\":..,\"daily_limit\":..,\"monthly_used\":..,\"monthly_limit\":..}` with null for a limit that is not set). A split is never parked for approval.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "`{\"error\":\"account_check_unavailable\"}`: the ownership lookup failed; `limit_check_unavailable` or `tenant_check_unavailable` (a limit check that could not run, also a usage lock wait that timed out): nothing was posted, retry."
          },
          "201": {
            "description": "Split transfer created"
          }
        }
      }
    },
    "/api/v1/transfers/batch": {
      "post": {
        "operationId": "createBatchTransfer",
        "tags": ["Transfers"],
        "summary": "Batch transfer with skip-and-continue for blocked accounts",
        "description": "Processes multiple transfers in a single request. Each transfer is\nindividually validated against the account guard (frozen/closed/woff\nstatus checks). Blocked transfers are skipped and recorded with ISO\n20022 StatusReasonCodes; remaining transfers proceed normally. Returns\na pacs.002-compatible batch result with accepted/rejected counts and\nper-rejection details. Maximum 1000 transfers per batch.\n\nWOFF recovery and adjustment transfers bypass the WOFF block per\nIFRS 9.B5.4.9 whitelist logic in the account guard.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["transfers"],
                "properties": {
                  "transfers": {
                    "type": "array",
                    "maxItems": 1000,
                    "items": {
                      "$ref": "#/components/schemas/BatchTransferItem"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "404": {
            "description": "`{\"error\":\"account_not_found\"}`: a leg is not an account of the posting tenant, or a platform account debited by a non-platform caller. Foreign and unknown ids get the same answer (DEC-0026)."
          },
          "503": {
            "description": "`{\"error\":\"account_check_unavailable\"}`: the ownership lookup failed; `limit_check_unavailable`: the usage locks of the batch's debit accounts could not be taken (nothing was posted)."
          },
          "200": {
            "description": "Batch result (pacs.002-compatible). An item whose fee cannot be priced is rejected with reason `AM02` and `fee_tier_not_matched` (no tier covers the amount) or `fee_currency_not_priced` (the type is priced, but not in this currency); not `TECH`: retrying does not help. Each item meets the limits of POST /api/v1/transfers: `AM02` with the reason (`Tenant single transfer limit exceeded`, the bank's daily and monthly ceilings once enforced, `Single|Daily|Monthly transaction limit exceeded` of the debit account, counting the items of this batch already recorded; a customer reads `The payment could not be processed.` for the bank's ceilings), `AG01` `Tenant suspended`, `TECH` `Limit check unavailable; resubmit this item`. Items are never parked for approval.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchTransferResult"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          }
        }
      }
    },
    "/api/v1/transfers/r-transactions": {
      "post": {
        "operationId": "processRTransaction",
        "tags": ["Transfers"],
        "summary": "Process inbound SEPA R-transaction (BR-EF-011 Phase 7-8)",
        "description": "Receives inbound SEPA R-transaction webhooks from banking providers.\nClassifies the R-transaction using ISO 20022 pacs.004 reason codes into\none of four types: Reject (pre-settlement, silent), Return (within holding\nperiod, voids pending), Refund (post-holding, customer-initiated),\nReversal (bank correction / Stornobuchung).\n\nAt least one original transfer reference must be provided for resolution.\nThe handler resolves by transfer_id, sepa_end_to_end_id, or external_id.\n\nA credit held in the ledger (HoldingPeriods, ledger hold): while its\nhold is pending, any R-transaction voids the pending ledger transfer\n(the credit was never available; the customer is never debited) and\nrecords status `voided`, `SETTLED_RETURNED`, with the R-transaction\ntype (REJECT, RETURN, ...) as the reason; sent again, it answers the\nsame without a second void. A partial return (`returned_amount`\nbelow the held amount) is refused, 422\n`partial_return_not_supported` (a held credit is returned whole). A\nhold already released goes the usual way (refund or reversal). When\nthe void cannot be confirmed, 503 `ledger_unavailable` (nothing\nrecorded; send it again); a hold the ledger released at its timeout\nis recorded `SETTLED_EXPIRED` and answered 422 `hold_expired`\n(operations).\n\nReturn deadlines follow the EPC SEPA Direct Debit rulebooks (D+5\ninterbank business days for Core, D+2 for B2B), subject to operational implementation and legal validation.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["reason_code"],
                "properties": {
                  "original_transfer_id": {
                    "type": "string",
                    "description": "Internal ledger engine transfer ID (hex)"
                  },
                  "original_end_to_end_id": {
                    "type": "string",
                    "description": "SEPA EndToEndId (max 35 chars)"
                  },
                  "original_external_id": {
                    "type": "string",
                    "description": "Provider-side reference"
                  },
                  "reason_code": {
                    "type": "string",
                    "description": "ISO 20022 ExternalStatusReason1Code (AC04, FRAD, CUST, etc.)"
                  },
                  "additional_info": {
                    "type": "string",
                    "description": "Free text from originator"
                  },
                  "returned_amount": {
                    "type": "integer",
                    "description": "Returned amount in cents (for partial returns)"
                  },
                  "currency": {
                    "type": "string",
                    "default": "EUR"
                  },
                  "is_b2b": {
                    "type": "boolean",
                    "default": false,
                    "description": "SEPA B2B scheme (D+2 instead of D+5)"
                  },
                  "provider_ref": {
                    "type": "string"
                  },
                  "value_date": {
                    "type": "string",
                    "description": "Value date (YYYY-MM-DD)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "R-transaction processed successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RTransactionResult"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "422": {
            "description": "R-transaction could not be processed (original not found or invalid state; `hold_expired`; `partial_return_not_supported`)"
          },
          "503": {
            "description": "`{\"error\":\"ledger_unavailable\"}`: the ledger hold of the original could not be voided yet; nothing recorded, send the R-transaction again."
          }
        }
      }
    },
    "/api/v1/fees/calculate": {
      "get": {
        "operationId": "calculateFeeGet",
        "tags": ["Fees"],
        "summary": "Preview fee for a transfer (query params)",
        "description": "Calculates the applicable fee for a given transfer type, amount, currency,\nand optional customer/tenant context. Returns the fee, the applied\nschedule, any customer-specific override, and (0.31.0, DEC-0038) the\ncharge bearer options of the rail, the total debited and the amount\nthe recipient gets, in minor units. Lets a client show the charges\nbefore the customer confirms, subject to operational implementation and legal\nvalidation. Same parameters and answer as the POST variant.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Event type (e.g. transfer_sepa_sct, fx_conversion). Required unless `rail` is given."
          },
          {
            "name": "rail",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/FeePreviewRail"
            }
          },
          {
            "name": "charge_bearer",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": ["slev", "sha", "our", "ben"]
            },
            "description": "Totals for this bearer, with the rules of `POST /api/v1/transfers`."
          },
          {
            "name": "beneficiary_bic",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "beneficiary_country",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 2,
              "maxLength": 2
            }
          },
          {
            "name": "amount",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            },
            "description": "Transfer amount in minor units"
          },
          {
            "name": "currency",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/Currency"
            }
          },
          {
            "name": "customer_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Customer UUID for override resolution"
          },
          {
            "name": "tenant_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Tenant UUID for schedule resolution (staff and services). Ignored for a customer JWT, which always prices its own tenant."
          }
        ],
        "responses": {
          "200": {
            "description": "Fee calculation result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FeeCalculation"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "calculateFeePost",
        "tags": ["Fees"],
        "summary": "Preview fee for a transfer (JSON body)",
        "description": "JSON body alternative for fee preview. Same logic as the GET variant.\n\nCharge bearer per rail (DEC-0038, 0.31.0). The rail is `rail`, else\nthe rail `type` names (`transfer_sepa_sct`, `sepa_sct`,\n`transfer_sepa_instant`, `transfer_sic`, `transfer_sic_instant`,\n`transfer_swift`, `wire_intl`, `transfer_internal`); a `type` that\nnames none (`fx_conversion`, `wire_domestic`, ...) has no bearer.\nWith only `rail`, its event type is priced.\n\n- SEPA SCT, SCT Inst, SIC, SIC IP: `charge_bearer_options`\n  `[\"slev\"]`, never a choice; `other_banks_may_deduct` false.\n- SWIFT: `[\"sha\"]`, plus `\"our\"` only when an OUR price is\n  configured for the tenant and currency and the beneficiary bank\n  (country of `beneficiary_bic`, else `beneficiary_country`) is\n  outside the EEA; an EEA or unknown bank is `[\"sha\"]`. No OUR\n  price is configured on any tenant today, so SWIFT is `[\"sha\"]`.\n  `other_banks_may_deduct` is true for `sha` and `ben`, false for\n  `our`: show that the recipient's bank and other banks may take\n  their own fees. The OUR price is `total_debit` of a second\n  preview with `charge_bearer` `our` minus `total_debit` of the\n  default. A `charge_bearer` `our` that is not offered answers as\n  `sha`, as `POST /api/v1/transfers` stores it.\n- Internal, FPS, no rail: `[]` and `default_charge_bearer` null.\n\n`total_debit` = `amount` + `total_fee`; `recipient_gets` = `amount`\n(our fee is never deducted under `slev`, `sha` or `our`). With\n`charge_bearer` `ben` (SWIFT, API only) `total_debit` = `amount`\nand `recipient_gets` = `amount` - `total_fee`. `POST\n/api/v1/transfers` with the same inputs debits `total_debit`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["amount", "currency"],
                "properties": {
                  "type": {
                    "type": "string",
                    "description": "Event type or fee type. Required unless `rail` is given."
                  },
                  "amount": {
                    "type": "integer",
                    "format": "int64",
                    "description": "Minor units"
                  },
                  "currency": {
                    "$ref": "#/components/schemas/Currency"
                  },
                  "customer_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "tenant_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Staff and services. Ignored for a customer JWT, which always prices its own tenant."
                  },
                  "rail": {
                    "$ref": "#/components/schemas/FeePreviewRail"
                  },
                  "charge_bearer": {
                    "type": "string",
                    "enum": ["slev", "sha", "our", "ben"],
                    "description": "Optional. The totals are for this bearer, with the rules\nof `POST /api/v1/transfers`: SEPA and SIC map anything but\n`ben` to `slev` and refuse `ben` (422); SWIFT takes `sha`,\n`our`, `ben` (else 400). Absent: the default.\n"
                  },
                  "beneficiary_bic": {
                    "type": "string",
                    "description": "SWIFT. The beneficiary bank's BIC; its country tells an EEA bank from another. Ignored when malformed."
                  },
                  "beneficiary_country": {
                    "type": "string",
                    "description": "SWIFT. ISO 3166-1 alpha-2 of the beneficiary bank, used when no BIC is given."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Fee calculation result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FeeCalculation"
                }
              }
            }
          },
          "400": {
            "description": "`Missing type field` (no `type` and no `rail`), `{\"error\":\"invalid_rail\"}`, `{\"error\":\"invalid_charge_bearer\"}` (SWIFT), `Invalid amount` (below 0 or out of range); `{\"error\":\"currency_required\"}` (no currency: never priced in a default one).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "`{\"error\":\"charge_bearer_not_allowed\"}` (`ben` on a rail other than SWIFT), `{\"error\":\"Fee exceeds transfer amount\"}` (SWIFT `ben` with a fee not below the amount), `{\"error\":\"fee_tier_not_matched\"}` (a schedule is in effect but no tier covers the amount: a transfer would be refused, never priced at 0); `{\"error\":\"fee_currency_not_priced\",...}` (the type is priced, but not in this currency): a transfer would be refused.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Database not available",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/fees/schedules": {
      "get": {
        "operationId": "listFeeSchedules",
        "tags": ["Fees"],
        "summary": "List a bank's fee schedules",
        "description": "The bank's schedules: active, scheduled (starting later) and\nswitched-off versions; `history=true` adds the superseded ones. A\nscheduled version whose date has come is made active on this read\n(pricing never waits for it: the engine prices with the version in\neffect at transfer time).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The bank (default the session's or `X-Tenant-ID`); required."
          },
          {
            "name": "history",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Fee schedules",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "schedules": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/FeeSchedule"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`tenant_required`"
          }
        }
      },
      "post": {
        "operationId": "createFeeSchedule",
        "tags": ["Fees"],
        "summary": "Create a fee schedule (first version)",
        "description": "One schedule per bank, fee type and currency. The schedule, its\ntiers and the audit row (`fee_schedule.created`) commit together.\nTiers: integer minor units; the first starts at 0, each ends where\nthe next starts, only the last is open-ended; rate in [0, 1) with at\nmost six decimals; `min_fee <= max_fee`. `effective_from` in the\nfuture makes it a scheduled version. Staff `bank_admin` (super_admin reads only, DEC-0042).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateFeeScheduleRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Schedule created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FeeSchedule"
                }
              }
            }
          },
          "400": {
            "description": "A tier problem (`tiers_empty`, `tiers_first_not_zero`, `tiers_not_contiguous`, `tiers_last_not_open`, `tier_range_invalid`, `tier_rate_invalid`, `tier_amount_invalid`, `tier_fee_bounds_invalid`), `unknown_fee_type`, `unsupported_currency`, `effective_from_in_past`"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "`schedule_exists`: the fee type and currency have an active or scheduled version"
          }
        }
      }
    },
    "/api/v1/fees/schedules/{scheduleId}": {
      "get": {
        "operationId": "getFeeSchedule",
        "tags": ["Fees"],
        "summary": "Get fee schedule with tiers",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "scheduleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Fee schedule with tier table",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FeeSchedule"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/fees/schedules/{scheduleId}/tiers": {
      "put": {
        "operationId": "updateFeeScheduleTiers",
        "tags": ["Fees"],
        "summary": "New version of a schedule's tiers (now or from a date)",
        "description": "Writes a new version (GoBD: the previous one is kept). Without\n`effective_from` (or with one in the past five minutes) the new\nversion is active at once and the active one superseded; with a\nlater date it is scheduled and replaces any scheduled version. The\nversion, its tiers and the audit row (`fee_schedule.version_created`,\nold and new) commit together; any failure writes nothing. Consumer\nprice increases need the notice the bank's jurisdiction requires\n(two months in the EEA).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "scheduleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["tiers"],
                "properties": {
                  "tiers": {
                    "description": "The tier table (an array, or the array as a JSON string).",
                    "oneOf": [
                      {
                        "type": "array",
                        "items": {
                          "$ref": "#/components/schemas/FeeTier"
                        }
                      },
                      {
                        "type": "string"
                      }
                    ]
                  },
                  "effective_from": {
                    "type": "string",
                    "format": "date-time"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The new version",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FeeSchedule"
                }
              }
            }
          },
          "400": {
            "description": "A tier problem or `effective_from_in_past`"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`wrong_state`: the version is neither active nor scheduled"
          }
        }
      }
    },
    "/api/v1/fees/schedules/{scheduleId}/deactivate": {
      "post": {
        "operationId": "deactivateFeeSchedule",
        "tags": ["Fees"],
        "summary": "Switch a schedule version off",
        "description": "The bank stops charging this fee type and currency: with no\nversion in effect the fee is 0. Reason required; audited\n(`fee_schedule.deactivated`). Staff `bank_admin` (super_admin reads only, DEC-0042).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "scheduleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReasonRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Switched off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FeeSchedule"
                }
              }
            }
          },
          "400": {
            "description": "`reason_required`"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`wrong_state`"
          }
        }
      }
    },
    "/api/v1/fees/schedules/{scheduleId}/activate": {
      "post": {
        "operationId": "activateFeeSchedule",
        "tags": ["Fees"],
        "summary": "Switch a schedule version on again",
        "description": "An inactive version with tiers becomes active (or scheduled, when\nits start lies ahead). 409 when its fee type and currency already\nhave a live version of that kind. Reason required; audited\n(`fee_schedule.activated`).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "scheduleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReasonRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Switched on",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FeeSchedule"
                }
              }
            }
          },
          "400": {
            "description": "`reason_required`"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`schedule_exists` or `wrong_state`"
          }
        }
      }
    },
    "/api/v1/fees/schedules/{scheduleId}/versions": {
      "get": {
        "operationId": "listFeeScheduleVersions",
        "tags": ["Fees"],
        "summary": "Version history of a schedule's fee type and currency",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "scheduleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Versions, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "versions": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/FeeSchedule"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/fees/overrides": {
      "get": {
        "operationId": "listFeeOverrides",
        "tags": ["Fees"],
        "summary": "A customer's special pricing",
        "description": "Live and upcoming special prices; `history=true` adds the ended ones.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "customer_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "history",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Special prices",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "overrides": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/FeeOverride"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createFeeOverride",
        "tags": ["Fees"],
        "summary": "Set a special price for a customer, fee type and currency",
        "description": "Pinned to a fee type and a currency (never \"every transfer\"), so it\nsurvives a new tier version. Ends the special price it replaces for\nthe same key (kept, `end_reason`). `percentage_override` in [0, 1)\nwith at most six decimals (a rate of 1 or more made every fee of\nthe customer fail; also a database CHECK since migration 265).\nRecorded against the admin session's user (a service-key caller\nnames it: `X-Admin-ID` / `X-User-ID`); audited\n(`fee_override.created`). Staff `bank_admin` (super_admin reads only, DEC-0042).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateFeeOverrideRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Special price created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FeeOverride"
                }
              }
            }
          },
          "400": {
            "description": "`unknown_fee_type`, `unsupported_currency`, `percentage_override_invalid`, `flat_fee_adj_invalid`, `reason_required`, `effective_from_in_past`, `invalid_input`"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/fees/overrides/{overrideId}": {
      "delete": {
        "operationId": "deleteFeeOverrideRetired",
        "tags": ["Fees"],
        "summary": "Retired (405 use_end)",
        "description": "Special prices are ended with a reason, never deleted; use `POST .../end`.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "overrideId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "405": {
            "description": "`use_end`"
          }
        }
      }
    },
    "/api/v1/fees/overrides/{overrideId}/end": {
      "post": {
        "operationId": "endFeeOverride",
        "tags": ["Fees"],
        "summary": "End a special price now",
        "description": "Sets `valid_until` to now with `ended_by` and `end_reason`; the row\nis kept (HGB \u00a7239) and audited (`fee_override.ended`). Staff `bank_admin` (super_admin reads only; DEC-0042: the bank's decision).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "overrideId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReasonRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Ended",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FeeOverride"
                }
              }
            }
          },
          "400": {
            "description": "`reason_required`"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/integration/iban/register": {
      "post": {
        "operationId": "registerIban",
        "tags": ["Integration"],
        "summary": "Link an IBAN to a ledger account and customer (DEC-0026)",
        "description": "The account must belong to the request tenant (finance_account_owner),\nthe customer must be of that tenant, and an IBAN registered for another\naccount or customer is never re-pointed. A retry with the same account\nand customer refreshes the row.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["iban", "account_id"],
                "properties": {
                  "iban": {
                    "type": "string"
                  },
                  "account_id": {
                    "type": "string",
                    "description": "Ledger account id (hex)"
                  },
                  "customer_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "country": {
                    "type": "string"
                  },
                  "account_name": {
                    "type": "string"
                  },
                  "currency": {
                    "type": "string"
                  },
                  "account_type": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Registered"
          },
          "400": {
            "description": "Missing iban, account_id not hex, invalid customer_id, or no tenant"
          },
          "404": {
            "description": "`{\"error\":\"account_not_found\"}` or `{\"error\":\"customer_not_found\"}` (foreign and unknown alike)"
          },
          "409": {
            "description": "`{\"error\":\"iban_taken\"}`: the IBAN is registered for another account or customer"
          },
          "503": {
            "description": "`{\"error\":\"account_check_unavailable\"}`"
          }
        }
      }
    },
    "/api/v1/holds": {
      "get": {
        "operationId": "listHolds",
        "tags": ["Holds"],
        "summary": "List active and historical authorization holds",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Hold list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "holds": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Hold"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createHold",
        "tags": ["Holds"],
        "summary": "Create authorization hold (reserve funds without settlement)",
        "description": "Creates a pending ledger transfer that reserves funds on the debit\naccount without settling to the credit account. The reserved amount is\nreflected in `pending_debits` on the source account balance. Holds must\nbe captured (settled) or voided (released) within the configurable expiry\nwindow (default 7 days per card scheme rules). Requires an\n`Idempotency-Key` header to prevent duplicate reservations.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateHoldRequest"
              }
            }
          }
        },
        "responses": {
          "404": {
            "description": "`{\"error\":\"account_not_found\"}`: a leg is not an account of the posting tenant, or a platform account debited by a non-platform caller. Foreign and unknown ids get the same answer (DEC-0026)."
          },
          "503": {
            "description": "`{\"error\":\"account_check_unavailable\"}`: the ownership lookup failed"
          },
          "201": {
            "description": "Hold created (pending ledger transfer)"
          }
        }
      }
    },
    "/api/v1/holds/{holdId}": {
      "get": {
        "operationId": "getHold",
        "tags": ["Holds"],
        "summary": "Retrieve hold details and current status",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/HoldId"
          }
        ],
        "responses": {
          "200": {
            "description": "Hold details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Hold"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/holds/{holdId}/capture": {
      "post": {
        "operationId": "captureHold",
        "tags": ["Holds"],
        "summary": "Capture hold (settle reserved funds)",
        "description": "Settles a pending hold by committing the ledger transfer. Supports\npartial capture where the settled amount is less than the originally\nreserved amount; the difference is automatically released. Only holds in\n`pending` status can be captured. The capture is idempotent when the\nsame `Idempotency-Key` is provided.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/HoldId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "422": {
            "description": "Hold not found, already settled, not a hold of the posting tenant, or a direct debit credit held until its holding period ends (HoldingPeriods; also for a platform caller) (same answer)"
          },
          "200": {
            "description": "Hold captured"
          }
        }
      }
    },
    "/api/v1/holds/{holdId}/void": {
      "post": {
        "operationId": "voidHold",
        "tags": ["Holds"],
        "summary": "Void hold (release all reserved funds)",
        "description": "Cancels a pending hold and releases all reserved funds back to the\nsource account. Only holds in `pending` status can be voided. The void\noperation creates a voiding entry in the ledger that zeroes the pending\ntransfer. This is idempotent with the same `Idempotency-Key`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/HoldId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "Hold voided"
          },
          "422": {
            "description": "Hold not found, already settled, not a hold of the posting tenant, or a direct debit credit held until its holding period ends (HoldingPeriods; voided only by a return) (same answer)"
          }
        }
      }
    },
    "/api/v1/assistant/messages": {
      "post": {
        "operationId": "postAssistantMessage",
        "tags": ["Customers"],
        "summary": "Ask the money assistant (BR-FM-012)",
        "description": "Customer JWT only. Answers from the customer's insights facts (summary,\nrecurring, forecast, notes, brief). Read only: it never moves money;\nactions only open an app screen, and the confirm card still applies.\nGuarded by the tenant feature `assistant` (`assistant_enabled`), off by default.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["message"],
                "properties": {
                  "message": {
                    "type": "string",
                    "maxLength": 1000
                  },
                  "conversation_id": {
                    "type": "string",
                    "maxLength": 64
                  },
                  "locale": {
                    "type": "string",
                    "example": "es-ES"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Assistant reply",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "reply": {
                      "type": "string"
                    },
                    "sources": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "enum": [
                              "summary",
                              "recurring",
                              "forecast",
                              "note",
                              "brief"
                            ]
                          },
                          "id": {
                            "type": "string",
                            "description": "Fact id"
                          },
                          "label": {
                            "type": "string",
                            "description": "Display name, or empty (the app names the kind)"
                          }
                        }
                      }
                    },
                    "actions": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "enum": [
                              "open_send",
                              "open_card_freeze",
                              "open_insights"
                            ]
                          },
                          "label": {
                            "type": "string",
                            "description": "Empty; the app names the screen from kind"
                          },
                          "params": {
                            "type": "object",
                            "description": "open_send: amount_minor, currency. open_card_freeze: card_id. open_insights: section, month."
                          }
                        }
                      }
                    },
                    "conversation_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body (message_required, message_too_long, invalid_conversation_id)"
          },
          "401": {
            "description": "Not authenticated"
          },
          "403": {
            "description": "Not a customer JWT, or assistant_disabled for the tenant"
          },
          "503": {
            "description": "assistant_unavailable (assistant service not registered or unreachable)"
          },
          "504": {
            "description": "assistant_timeout"
          }
        }
      }
    },
    "/api/v1/limits": {
      "get": {
        "operationId": "listLimits",
        "tags": ["Limits"],
        "summary": "The bank's transaction limits (filtered and paged)",
        "description": "The request bank's limits at tenant, customer and account scope,\nfiltered and paged by finance-api. Values are minor units of\n`currency`; null means no limit, 0 allows nothing (migration 266).\nDeleted limits only with `include_deleted=true`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "scope",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": ["tenant", "customer", "account"]
            }
          },
          {
            "name": "customer_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "currency",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "include_deleted",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 100
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Limits list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "limits": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/TransactionLimit"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`invalid_input`, `unsupported_currency`"
          }
        }
      },
      "post": {
        "operationId": "createLimit",
        "tags": ["Limits"],
        "summary": "Create a transaction limit",
        "description": "One scope: the bank (tenant default, optionally per customer type),\na customer or a ledger account. A customer limit is an override\n(the type the transfer check enforces) and needs `notes`. All\nthree values are required: an integer >= 0 in minor units or null\n(no limit); single <= daily <= monthly. The platform's ceilings for\nthe bank apply on top (DEC-0042). Staff `bank_admin` (super_admin reads only, DEC-0042); audited (`limit.created`).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateLimitRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Limit created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransactionLimit"
                }
              }
            }
          },
          "400": {
            "description": "`limit_value_required`, `limit_value_invalid`, `limit_order_invalid`, `limit_window_invalid`, `unsupported_currency`, `note_required`, `invalid_input`"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`limit_exists`: a live limit has this scope and currency"
          }
        }
      }
    },
    "/api/v1/limits/tenant-ceilings/enforcement": {
      "post": {
        "operationId": "setTenantCeilingEnforcement",
        "tags": ["Limits"],
        "summary": "Switch a bank's daily and monthly ceilings on or off (platform)",
        "description": "The platform's ceilings of a bank (DEC-0042) apply to its outgoing customer payments only once switched on here, after review against GET /api/v1/limits/tenant-ceilings (review M6; default off, so the stored defaults do not start refusing payments by themselves). A super_admin in the platform scope only; a reason is required; audited with old and new values (`tenant_ceilings.enforced` / `tenant_ceilings.not_enforced`). The column is changed in the platform scope only (database trigger). The single-transfer ceiling is always checked.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["tenant_id", "enforced", "reason"],
                "properties": {
                  "tenant_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "enforced": {
                    "type": "boolean"
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 3
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The bank's switch now",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "tenant_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "ceilings_enforced": {
                      "type": "boolean"
                    },
                    "ceilings_enforced_at": {
                      "type": "string",
                      "nullable": true
                    },
                    "ceilings_enforced_by": {
                      "type": "string",
                      "nullable": true
                    },
                    "limits": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`invalid_input`, `enforced_invalid`, `note_required`"
          },
          "403": {
            "description": "`platform_only`"
          },
          "404": {
            "description": "`not_found`"
          }
        }
      }
    },
    "/api/v1/limits/tenant-ceilings": {
      "get": {
        "operationId": "getTenantCeilingReport",
        "tags": ["Limits"],
        "summary": "The banks' stored ceilings against their last 30 days (platform)",
        "description": "Read-only report for the platform's review before it switches a bank's daily and monthly ceilings on (finance_tenant.ceilings_enforced, migration 266; default off). Per bank: the switch, the stored single, daily and monthly ceilings (EUR cents, defaults applied: 50,000.00 / 100,000.00 / 1,000,000.00 EUR), the highest day and the total of the last 30 days of outgoing customer payments (EUR cents, reference rates), and whether they lie above the daily or monthly ceiling. A super_admin in the platform scope only.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "One entry per bank",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "tenant_id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "name": {
                        "type": "string"
                      },
                      "ceilings_enforced": {
                        "type": "boolean"
                      },
                      "single_ceiling": {
                        "type": "integer",
                        "format": "int64"
                      },
                      "daily_ceiling": {
                        "type": "integer",
                        "format": "int64"
                      },
                      "monthly_ceiling": {
                        "type": "integer",
                        "format": "int64"
                      },
                      "max_day_30d": {
                        "type": "integer",
                        "format": "int64"
                      },
                      "total_30d": {
                        "type": "integer",
                        "format": "int64"
                      },
                      "daily_exceeded_30d": {
                        "type": "boolean"
                      },
                      "total_30d_above_monthly": {
                        "type": "boolean"
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`platform_only`"
          }
        }
      }
    },
    "/api/v1/limits/card-fx": {
      "get": {
        "operationId": "getCardFxFallbackCap",
        "tags": ["Limits"],
        "summary": "Card FX fallback-rate cap of a tenant",
        "description": "Card authorizations in another currency are priced at the live FX\nmid rate. When only the static fallback rate is available, an\nauthorization is allowed up to this amount (default EUR 100.00);\nabove it the JIT gateway declines `FX_UNAVAILABLE`. Staff and\nservices only (customer JWT: 403).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The cap",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CardFxCap"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      },
      "put": {
        "operationId": "setCardFxFallbackCap",
        "tags": ["Limits"],
        "summary": "Set the card FX fallback-rate cap of a tenant",
        "description": "Audited (event 700 config_updated). 0 means never on a fallback rate. A bank setting (DEC-0042): the bank's bank_admin changes it for its own bank; super_admin and other roles read it only (403 forbidden_role); a service with its key passes.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CardFxCap"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CardFxCap"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/limits/{limitId}": {
      "get": {
        "operationId": "getLimit",
        "tags": ["Limits"],
        "summary": "Retrieve limit configuration by ID",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/LimitId"
          }
        ],
        "responses": {
          "200": {
            "description": "Limit details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransactionLimit"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "put": {
        "operationId": "updateLimit",
        "tags": ["Limits"],
        "summary": "Change limit values",
        "description": "The values sent change (an absent one stays; null is no limit);\nthe database checks single <= daily <= monthly on the merged row.\n`valid_from` / `valid_until` move the validity window the same way.\nAudited (`limit.updated`, old and new). PATCH is the same.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/LimitId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "single_transaction_limit": {
                    "type": "integer",
                    "format": "int64",
                    "minimum": 0,
                    "nullable": true
                  },
                  "daily_limit": {
                    "type": "integer",
                    "format": "int64",
                    "minimum": 0,
                    "nullable": true
                  },
                  "monthly_limit": {
                    "type": "integer",
                    "format": "int64",
                    "minimum": 0,
                    "nullable": true
                  },
                  "notes": {
                    "type": "string",
                    "maxLength": 1000
                  },
                  "valid_from": {
                    "type": "string",
                    "nullable": true,
                    "description": "ISO 8601 (without an offset, the bank's time zone); null starts the limit now; absent keeps it. A bank default cannot start later."
                  },
                  "valid_until": {
                    "type": "string",
                    "nullable": true,
                    "description": "ISO 8601 (without an offset, the bank's time zone); null makes the limit open ended; absent keeps it. A bank default has none."
                  },
                  "replace": {
                    "type": "boolean",
                    "description": "`true`: the officer confirmed that a window on a customer or account limit in force now replaces it (outside the window the bank default applies); else 409 `limit_replace_required`."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "409": {
            "description": "`{\"error\":\"aml_provider_limit_exists\"}`: an AML provider's limit is not changed here; `{\"error\":\"limit_replace_required\"}`: a window on a customer or account limit in force now, without `replace: true`."
          },
          "200": {
            "description": "Limit updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransactionLimit"
                }
              }
            }
          },
          "400": {
            "description": "`limit_value_invalid`, `limit_order_invalid`, `limit_window_invalid` (valid_from not before valid_until on the merged row, or a valid_until sent that is not in the future), `note_required`"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "delete": {
        "operationId": "deleteLimitRetired",
        "tags": ["Limits"],
        "summary": "Retired (405 use_delete)",
        "description": "Limits are deleted with a reason; use `POST .../delete`.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/LimitId"
          }
        ],
        "responses": {
          "405": {
            "description": "`use_delete`"
          }
        }
      }
    },
    "/api/v1/limits/{limitId}/delete": {
      "post": {
        "operationId": "deleteLimit",
        "tags": ["Limits"],
        "summary": "Delete a limit (soft, with a reason)",
        "description": "The limit no longer applies; the row is kept with `deleted_at`,\n`deleted_by` and `delete_reason` and audited (`limit.deleted`, old\nvalues). Staff `bank_admin` (super_admin reads only, DEC-0042).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/LimitId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReasonRequest"
              }
            }
          }
        },
        "responses": {
          "409": {
            "description": "`{\"error\":\"aml_provider_limit_exists\"}`: an AML provider's limit is not deleted here."
          },
          "200": {
            "description": "Limit deleted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransactionLimit"
                }
              }
            }
          },
          "400": {
            "description": "`note_required`"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/currencies": {
      "get": {
        "operationId": "listCurrencies",
        "tags": ["FX"],
        "summary": "Currencies the tenant may use, with ISO 4217 exponents",
        "description": "The tenant is taken from the JWT (then `X-Tenant-ID`). A tenant with no\ncurrency whitelist is unrestricted; with no tenant at all (admin) every\nregistry currency is listed. `decimals` is the minor-unit exponent to\nuse for every amount in that currency (DEC-0016).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Allowed currencies in registry order",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "currencies": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CurrencyInfo"
                      }
                    }
                  }
                },
                "example": {
                  "currencies": [
                    {
                      "code": "EUR",
                      "decimals": 2,
                      "name": "Euro"
                    },
                    {
                      "code": "JPY",
                      "decimals": 0,
                      "name": "Japanese Yen"
                    },
                    {
                      "code": "KWD",
                      "decimals": 3,
                      "name": "Kuwaiti Dinar"
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/fx/rates": {
      "get": {
        "operationId": "getFxRates",
        "tags": ["FX"],
        "summary": "Retrieve exchange rates (EUR base, static fallback)",
        "description": "Returns current exchange rates with EUR as the base currency. Falls back\nto static reference rates if the rate provider is unavailable. Rates are\nexpressed as mid-market rates; actual conversion rates include the\nconfigured spread (basis points) per currency pair.\n",
        "responses": {
          "200": {
            "description": "Current exchange rates"
          }
        }
      }
    },
    "/api/v1/fx/rates/cached": {
      "get": {
        "operationId": "getCachedFxRates",
        "tags": ["FX"],
        "summary": "Retrieve cached exchange rates with expiry metadata",
        "description": "Returns rates from the database cache with source attribution and\nexpiry timestamp. Cache TTL is 1 hour. Includes the rate provider name,\nlast refresh timestamp, and `expires_at` for client-side staleness detection.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Cached rates with metadata (source, expires_at)"
          }
        }
      }
    },
    "/api/v1/fx/rates/refresh": {
      "post": {
        "operationId": "refreshFxRates",
        "tags": ["FX"],
        "summary": "Reset expired rates to the static fallback table (platform)",
        "description": "Writes the static fallback rate of every default currency whose\ncached rate has expired (a still-valid feed rate or override is\nkept) and answers how many rows it wrote (`refreshed`, `source`\n`static`). The market feed itself is the FxRateRefresh workflow.\n\nReference rates are platform data (DEC-0042): the service key or a\nstaff `super_admin` in the platform scope; bank roles are 403\n`forbidden_role`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Rows written from the static table",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "refreshed": {
                      "type": "integer",
                      "example": 3
                    },
                    "source": {
                      "type": "string",
                      "example": "static"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`forbidden_role`: not the service key or a platform super_admin"
          }
        }
      }
    },
    "/api/v1/fx/rates/upsert": {
      "post": {
        "operationId": "upsertFxRate",
        "tags": ["FX"],
        "summary": "Upsert exchange rate from external provider",
        "description": "Inserts or updates a single exchange rate for a currency pair (EUR base).\nUsed for receiving rate feeds from external providers. The `source`\nfield attributes the rate origin for audit purposes. A feed does not\nreplace an active manual override before it expires (DEC-0042).\nThe service key or a staff `super_admin` in the platform scope; bank\nroles are 403 `forbidden_role`. Manual corrections go through\n`POST /api/v1/fx/rates/override`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["quote_currency", "rate"],
                "properties": {
                  "quote_currency": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 3
                  },
                  "rate": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  },
                  "source": {
                    "type": "string",
                    "default": "external"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Rate upserted"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          }
        }
      }
    },
    "/api/v1/fx/rates/bulk-upsert": {
      "post": {
        "operationId": "bulkUpsertFxRates",
        "tags": ["FX"],
        "summary": "Bulk upsert exchange rates from external provider",
        "description": "Inserts or updates multiple EUR-based exchange rates in a single call.\nRates are encoded as comma-delimited \"CUR:rate\" pairs for lightweight\nparsing. Used by the FX rate refresh workflow after fetching rates from\nthe ECB daily XML feed. Each rate is written to the cache layer (30min TTL) and\ndatabase (24h expiry). Performance: ~10ms for 8 currencies vs ~96s\nwith sequential single-rate calls to the rate provider. A currency\nwith an active manual override keeps the override until it expires\n(DEC-0042). The service key or a staff `super_admin` in the platform\nscope; bank roles are 403 `forbidden_role`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["rates"],
                "properties": {
                  "rates": {
                    "type": "string",
                    "description": "Comma-delimited CUR:rate pairs",
                    "example": "USD:1.085000,GBP:0.855000,CHF:0.945000"
                  },
                  "source": {
                    "type": "string",
                    "default": "bulk",
                    "example": "ecb"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Rates upserted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "example": "ok"
                    },
                    "upserted": {
                      "type": "integer",
                      "example": 8
                    },
                    "source": {
                      "type": "string",
                      "example": "ecb"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          }
        }
      }
    },
    "/api/v1/fx/quote": {
      "post": {
        "operationId": "getFxQuote",
        "tags": ["FX"],
        "summary": "Request FX conversion quote (time-limited, persisted)",
        "description": "Generates a binding FX quote for the specified currency pair and amount.\nThe quote is persisted to the database with a time-limited validity window\n(configurable, default 5 minutes). The quoted rate includes the\ntenant-specific spread (basis points). Requires the tenant to have the\n`fx` feature flag enabled. Expired quotes must be re-requested.\n\nThe fee uses the same tenant and customer as `/fx/convert`: the JWT\ntenant (then `X-Tenant-ID`) and, for a customer JWT, the JWT customer.\nSo `fee_amount`, `net_amount` and `to_amount` are what the conversion\nwill book. With no tenant at all (admin preview) the fee is 0.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FxQuoteRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "FX quote",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FxQuote"
                }
              }
            }
          },
          "400": {
            "description": "`{\"error\":\"invalid_amount\"}` (amount missing or not positive), or missing currencies",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "`{\"error\":\"tenant_mismatch\"}` when a body tenant_id differs from the JWT tenant",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "`{\"error\":\"amount_below_fee\"}`: the fee takes the whole amount. `fee_tier_not_matched` (no tier of the fee schedule of the bank covers the amount: refused, never priced at 0, not retryable), `fee_currency_not_priced` (the bank prices this payment type, but not in this currency: refused, never free), `currency_required`: staff and service callers get the code; a customer JWT gets `{\"error\":\"payment_not_possible\",\"message\":\"The payment could not be processed.\"}`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "`{\"error\":\"quote_unavailable\"}` (the quote could not be stored) or `fee_calculation_unavailable`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/fx/convert": {
      "post": {
        "operationId": "executeFxConversion",
        "tags": ["FX"],
        "summary": "Execute FX conversion (cross-currency ledger transfer)",
        "description": "Executes a foreign exchange conversion as a pair of ledger transfers:\ndebit from the source currency account, credit to the target currency\naccount at the quoted rate. The FX spread is captured as platform revenue.\nRequires the tenant `fx` feature flag. The ledger legs are atomic.\n\n- **Customer JWT:** both `from_account_id` and `to_account_id` must be\n  the caller's own accounts (403 otherwise). Frozen, closed or\n  written-off accounts are refused (422).\n- **With `quote_id`:** the quote is claimed once. The body's\n  currencies and amount must equal the quote's (400\n  `quote_mismatch`); the conversion books the quote's own fee, rate\n  and `to_amount`. A used, expired or unknown quote returns 400\n  `Quote expired or not found`. Reusing the quote is the only replay\n  protection: `Idempotency-Key` is not evaluated by this endpoint.\n- **Without `quote_id`:** priced live (mid-market rate, tenant FX fee).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FxConvertRequest"
              }
            }
          }
        },
        "responses": {
          "503": {
            "description": "`{\"error\":\"account_check_unavailable\"}`: the ownership lookup failed. A check that could not run (`account_guard_unavailable`, `fee_calculation_unavailable`, `fee_account_unavailable`, `deposit_cap_unavailable`, `fx_rate_unavailable` to staff and service callers): a customer JWT gets `{\"error\":\"try_again_later\",\"message\":\"The payment cannot be processed right now. Please try again later.\"}` with `Retry-After: 1`, as on POST /api/v1/transfers. Nothing was converted."
          },
          "200": {
            "description": "Conversion executed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "conversion_id": {
                      "type": "string"
                    },
                    "from_amount": {
                      "type": "integer",
                      "format": "int64"
                    },
                    "to_amount": {
                      "type": "integer",
                      "format": "int64"
                    },
                    "net_amount": {
                      "type": "integer",
                      "format": "int64"
                    },
                    "fee_amount": {
                      "type": "integer",
                      "format": "int64"
                    },
                    "rate": {
                      "type": "number"
                    },
                    "spread_bps": {
                      "type": "integer"
                    },
                    "status": {
                      "type": "string",
                      "enum": ["completed"]
                    },
                    "from_decimals": {
                      "type": "integer"
                    },
                    "to_decimals": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing or invalid account ids, `{\"error\":\"invalid_amount\"}`, `{\"error\":\"quote_mismatch\"}`, quote expired or not found, or ledger rejection (insufficient funds)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "`{\"error\":\"account_not_found\"}`: debit or credit account is not the authenticated customer's (same answer as an unknown id)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "`{\"error\":\"amount_below_fee\"}` (specific for every caller). Account status restriction, `fee_tier_not_matched` (no tier of the fee schedule of the bank covers the amount: refused, never priced at 0, not retryable), `fee_currency_not_priced` (the bank prices this payment type, but not in this currency: refused, never free), `currency_required`, `deposit_cap_exceeded` and `intake_blocked`: staff and service callers get the specific body; a customer JWT gets `{\"error\":\"payment_not_possible\",\"message\":\"The payment could not be processed.\"}`, as on POST /api/v1/transfers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/fx/rates/override": {
      "post": {
        "operationId": "overrideFxRate",
        "tags": ["FX"],
        "summary": "Manual override of one reference rate (platform, DEC-0042)",
        "description": "Sets the EUR rate of one currency for every bank until it expires\n(1 to 720 hours, default 24). Only a staff `super_admin` in the\nplatform scope (403 `forbidden_role` for every other role and the\nservice key: a change names a person; 403 `platform_scope_required`\nwith an `X-Tenant-ID`). The person is the session's.\n\n**Band:** the override is measured against the market rate (the last\nrate a provider feed or the static fallback wrote,\n`finance_fx_rates.market_rate`). Within 500 basis points (5 %) it\napplies at once (200 `applied`). Further out it becomes a request\n(202 `pending_second_approval`) that a different `super_admin`\napproves within 24 hours\n(`POST /api/v1/fx/rates/overrides/{requestId}/approve`); one pending\nrequest per currency (409 `override_pending`).\n\n**Expiry:** the rate row expires with the override; readers fall\nback to the static table until the next feed, and a feed does not\nreplace the override before it expires.\n\nEvery change writes a rate history row (`changed_by`\n`staff:<id>`) and a `platform.setting.changed` audit row\n(`setting` `fx_override`).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["quote_currency", "rate", "reason"],
                "properties": {
                  "quote_currency": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 3,
                    "example": "CHF",
                    "description": "A supported currency other than EUR"
                  },
                  "rate": {
                    "type": "number",
                    "format": "double",
                    "exclusiveMinimum": 0,
                    "example": 0.952
                  },
                  "expires_hours": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 720,
                    "default": 24
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Applied (within the band)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FxOverrideApplied"
                }
              }
            }
          },
          "202": {
            "description": "Outside the band, waiting for a second super_admin",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": ["pending_second_approval"]
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "quote_currency": {
                      "type": "string"
                    },
                    "rate": {
                      "type": "number"
                    },
                    "market_rate": {
                      "type": "number"
                    },
                    "deviation_bps": {
                      "type": "integer"
                    },
                    "band_bps": {
                      "type": "integer",
                      "example": 500
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`invalid_field` with `field` (quote_currency, rate, expires_hours, reason)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          },
          "403": {
            "description": "`forbidden_role`, `platform_scope_required`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          },
          "409": {
            "description": "`override_pending`: a request of this currency waits",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/fx/rates/overrides": {
      "get": {
        "operationId": "listFxOverrides",
        "tags": ["FX"],
        "summary": "Active overrides and the override requests of the last 30 days",
        "description": "A staff `super_admin` in the platform scope. `active`: overrides that\nhave not expired (rate, market rate, deviation, expiry, who set and\nwho approved, the reason). `requests`: newest first, at most 100;\na pending request older than 24 hours reads `expired`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Overrides and requests",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "band_bps": {
                      "type": "integer",
                      "example": 500
                    },
                    "request_valid_hours": {
                      "type": "integer",
                      "example": 24
                    },
                    "active": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "quote_currency": {
                            "type": "string"
                          },
                          "rate": {
                            "type": "number"
                          },
                          "market_rate": {
                            "type": ["number", "null"]
                          },
                          "deviation_bps": {
                            "type": ["integer", "null"]
                          },
                          "expires_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "overridden_by": {
                            "type": ["string", "null"]
                          },
                          "overridden_by_name": {
                            "type": ["string", "null"]
                          },
                          "approved_by": {
                            "type": ["string", "null"]
                          },
                          "approved_by_name": {
                            "type": ["string", "null"]
                          },
                          "reason": {
                            "type": ["string", "null"]
                          }
                        }
                      }
                    },
                    "requests": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "quote_currency": {
                            "type": "string"
                          },
                          "rate": {
                            "type": "number"
                          },
                          "market_rate": {
                            "type": "number"
                          },
                          "deviation_bps": {
                            "type": "integer"
                          },
                          "expires_hours": {
                            "type": "integer"
                          },
                          "reason": {
                            "type": "string"
                          },
                          "requested_by": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "requested_by_name": {
                            "type": ["string", "null"]
                          },
                          "requested_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "pending",
                              "approved",
                              "rejected",
                              "expired"
                            ]
                          },
                          "decided_by": {
                            "type": ["string", "null"]
                          },
                          "decided_by_name": {
                            "type": ["string", "null"]
                          },
                          "decided_at": {
                            "type": ["string", "null"]
                          },
                          "decision_reason": {
                            "type": ["string", "null"]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`forbidden_role`, `platform_scope_required`"
          }
        }
      }
    },
    "/api/v1/fx/rates/overrides/{requestId}/approve": {
      "post": {
        "operationId": "approveFxOverride",
        "tags": ["FX"],
        "summary": "A second super_admin applies an override outside the band",
        "description": "Four-eyes (DEC-0042): a staff `super_admin` in the platform scope\nother than the requester (403 `four_eyes_required`). Applies the\nrequest with both people named. A request older than 24 hours\nexpires instead (409 `request_expired`); a decided one is 409\n`request_decided`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "requestId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Applied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FxOverrideApplied"
                }
              }
            }
          },
          "403": {
            "description": "`four_eyes_required`, `forbidden_role`, `platform_scope_required`"
          },
          "404": {
            "description": "`not_found`"
          },
          "409": {
            "description": "`request_decided`, `request_expired`"
          }
        }
      }
    },
    "/api/v1/fx/rates/overrides/{requestId}/reject": {
      "post": {
        "operationId": "rejectFxOverride",
        "tags": ["FX"],
        "summary": "Reject an override request (the requester withdraws it)",
        "description": "Any staff `super_admin` in the platform scope, with a reason (400\n`invalid_field` without one).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "requestId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["reason"],
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Rejected",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": ["rejected"]
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`not_found`"
          },
          "409": {
            "description": "`request_decided`"
          }
        }
      }
    },
    "/api/v1/fx/rates/override/{currency}/end": {
      "post": {
        "operationId": "endFxOverride",
        "tags": ["FX"],
        "summary": "End an active override now",
        "description": "A staff `super_admin` in the platform scope, with a reason. The\noverride row expires now; readers use the static table until the\nnext feed (run the FxRateRefresh workflow for market rates).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "currency",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 3,
              "maxLength": 3
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["reason"],
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Ended",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": ["ended"]
                    },
                    "quote_currency": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`no_active_override`"
          }
        }
      }
    },
    "/api/v1/fx/rates/history": {
      "get": {
        "operationId": "getFxRateHistory",
        "tags": ["FX"],
        "summary": "Rate change audit trail (last 100 entries)",
        "description": "Returns the most recent 100 rate change events across all EUR-based\ncurrency pairs. Each entry records the new rate, previous rate, source\n(alpha_vantage, static_refresh, manual_override), change type, reviewer\nidentity (for manual changes), and timestamp. Used for regulatory audit\nand operational monitoring.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Rate change history",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "history": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/FxRateHistory"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/fx/spreads": {
      "get": {
        "operationId": "listFxSpreads",
        "tags": ["FX"],
        "summary": "List spread configurations per currency pair",
        "description": "Returns all spread configurations including global defaults and\ntenant-specific rows. Spreads are in basis points (1 bps = 0.01%).\n**Not applied to any quote** (`applied: false`): a bank's FX margin\nis its `fx` fee schedule (BR-EF-021, DEC-0042).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Spread configurations",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "spreads": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/FxSpreadConfig"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "upsertFxSpread",
        "tags": ["FX"],
        "summary": "Create or update spread configuration for a currency pair",
        "description": "Creates or updates the global spread configuration of a EUR-based\ncurrency pair (1-1000 basis points). Not applied to quotes (see the\nlist). A staff `super_admin` in the platform scope only (403\n`forbidden_role` otherwise); `updated_by` is the session's person,\nand `tenant_id` and `updated_by` in the body are ignored\n(DEC-0042).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["quote_currency", "spread_bps"],
                "properties": {
                  "quote_currency": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 3,
                    "example": "USD"
                  },
                  "spread_bps": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 1000,
                    "example": 50
                  },
                  "tenant_id": {
                    "type": "string",
                    "format": "uuid",
                    "deprecated": true,
                    "description": "Ignored (global rows only)"
                  },
                  "updated_by": {
                    "type": "string",
                    "deprecated": true,
                    "description": "Ignored (the session's person)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Spread configuration saved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          }
        }
      }
    },
    "/api/v1/insights/summary": {
      "get": {
        "operationId": "getInsightsSummary",
        "tags": ["Insights"],
        "summary": "Month summary per currency",
        "description": "Spent, received, by category, by merchant (top 10) and the usual spend\n(average of the 3 months before, over the months with history). Own\naccount moves and FX legs are not spending. Card spending counts\nsettled and authorized amounts.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "month",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{4}-[0-9]{2}$"
            },
            "description": "YYYY-MM, default the current month (UTC)"
          },
          {
            "name": "account_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Registry id or ledger id of one of the customer's accounts"
          }
        ],
        "responses": {
          "200": {
            "description": "Summary",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InsightsSummary"
                }
              }
            }
          },
          "400": {
            "description": "Bad month",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Not authenticated"
          },
          "403": {
            "description": "Not a customer JWT"
          },
          "404": {
            "description": "Account not found for this customer"
          }
        }
      }
    },
    "/api/v1/insights/recurring": {
      "get": {
        "operationId": "getInsightsRecurring",
        "tags": ["Insights"],
        "summary": "Recurring series",
        "description": "Same merchant or payee, amount within 10 percent, interval of 7, 14,\n28 to 31, 90 (89 to 92) or 365 (365 to 366) days, at least 3 times.\nA regular inflow from one payer is `salary`; a regular monthly outflow\nby transfer to one payee is `rent`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Series, soonest next date first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["method", "series"],
                  "properties": {
                    "method": {
                      "type": "string",
                      "example": "rules_v1"
                    },
                    "series": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/InsightsSeries"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Not authenticated"
          },
          "403": {
            "description": "Not a customer JWT"
          }
        }
      }
    },
    "/api/v1/insights/forecast": {
      "get": {
        "operationId": "getInsightsForecast",
        "tags": ["Insights"],
        "summary": "Month end balance forecast for one account",
        "description": "Today's available balance, minus recurring bills still due this month,\nplus expected income, minus the mean daily discretionary spend of the\nlast 90 days times the days left. `low_minor`/`high_minor` are 1.28\nstandard deviations of the daily spend scaled by the square root of\nthe days left. Under 60 days of history `status` is\n`not_enough_history` and the amounts are null. Default account: the\ncustomer's first account.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "account_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Forecast",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InsightsForecast"
                }
              }
            }
          },
          "401": {
            "description": "Not authenticated"
          },
          "403": {
            "description": "Not a customer JWT"
          },
          "404": {
            "description": "No account",
            "or account not found for this customer": null
          }
        }
      }
    },
    "/api/v1/insights/notes": {
      "get": {
        "operationId": "getInsightsNotes",
        "tags": ["Insights"],
        "summary": "Notes of the last 30 days",
        "description": "Kinds: `duplicate_charge` (same card, merchant, amount within 10\nminutes, both settled), `price_rise` (recurring amount 15 percent or\nmore above its median), `unusual_charge` (card charge above the\ncustomer's p99 for the category, at least 10 earlier charges),\n`card_testing` (3 or more declined or under 2 major unit\nauthorizations on one card within 5 minutes), `new_country_night`\n(never seen merchant country between 00:00 and 05:00 local),\n`velocity` (today's authorizations over the 30 day p95). Duplicate and\nfraud notes are `warning`, the rest `info`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tz_offset_minutes",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": -840,
              "maximum": 840,
              "default": 0
            },
            "description": "Customer's UTC offset for local time rules"
          }
        ],
        "responses": {
          "200": {
            "description": "Notes, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["method", "notes"],
                  "properties": {
                    "method": {
                      "type": "string",
                      "example": "rules_v1"
                    },
                    "window_days": {
                      "type": "integer",
                      "example": 30
                    },
                    "notes": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/InsightsNote"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad tz_offset_minutes"
          },
          "401": {
            "description": "Not authenticated"
          },
          "403": {
            "description": "Not a customer JWT"
          }
        }
      }
    },
    "/api/v1/insights/brief": {
      "get": {
        "operationId": "getInsightsBrief",
        "tags": ["Insights"],
        "summary": "Up to 3 fact lines for the day",
        "description": "In order: warning notes, the month end forecast, spend so far against\nthe usual month pro rated to today, the next bill. Keys:\n`insights.brief.warning_notes`, `insights.brief.forecast`,\n`insights.brief.above_usual`, `insights.brief.below_usual`,\n`insights.brief.on_track`, `insights.brief.bill_next`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tz_offset_minutes",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": -840,
              "maximum": 840,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Brief",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["method", "lines"],
                  "properties": {
                    "method": {
                      "type": "string",
                      "example": "rules_v1"
                    },
                    "date": {
                      "type": "string",
                      "format": "date"
                    },
                    "lines": {
                      "type": "array",
                      "maxItems": 3,
                      "items": {
                        "type": "object",
                        "required": ["key", "params"],
                        "properties": {
                          "key": {
                            "type": "string"
                          },
                          "params": {
                            "$ref": "#/components/schemas/InsightsParams"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Not authenticated"
          },
          "403": {
            "description": "Not a customer JWT"
          }
        }
      }
    },
    "/api/v1/insights/accounts": {
      "get": {
        "operationId": "getInsightsAccounts",
        "tags": ["Insights"],
        "summary": "Every own account with its balance and this month's money in and out",
        "description": "0.26.2. The customer's own accounts (the JWT's customer, or the\nservice caller's `X-Customer-ID`): name, type, currency, the masked\nIBAN, available and booked balance from the ledger, money in and out\nthis month, the last `recent` movements; totals per currency. Card\nspending counts in the account's currency. The figures of the money\nassistant and of the support AI's `account_balances` tool.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "recent",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 10,
              "default": 5
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Accounts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "method",
                    "as_of",
                    "month",
                    "accounts",
                    "totals"
                  ],
                  "properties": {
                    "method": {
                      "type": "string",
                      "example": "rules_v1"
                    },
                    "as_of": {
                      "type": "string",
                      "format": "date"
                    },
                    "month": {
                      "type": "string",
                      "example": "2026-10"
                    },
                    "accounts": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "account_id",
                          "currency",
                          "available_minor",
                          "booked_minor",
                          "month_in_minor",
                          "month_out_minor",
                          "recent"
                        ],
                        "properties": {
                          "account_id": {
                            "type": "string",
                            "description": "The IBAN registry id",
                            "else the ledger id.": null
                          },
                          "name": {
                            "type": "string",
                            "nullable": true
                          },
                          "type": {
                            "type": "string",
                            "nullable": true
                          },
                          "currency": {
                            "type": "string"
                          },
                          "iban_masked": {
                            "type": "string",
                            "nullable": true,
                            "example": "ES22 \u2022\u2022\u2022\u2022 0001"
                          },
                          "available_minor": {
                            "type": "integer",
                            "nullable": true
                          },
                          "booked_minor": {
                            "type": "integer",
                            "nullable": true
                          },
                          "pending_out_minor": {
                            "type": "integer",
                            "nullable": true
                          },
                          "month_in_minor": {
                            "type": "integer"
                          },
                          "month_out_minor": {
                            "type": "integer"
                          },
                          "recent": {
                            "type": "array",
                            "maxItems": 10,
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string"
                                },
                                "date": {
                                  "type": "string",
                                  "format": "date"
                                },
                                "amount_minor": {
                                  "type": "integer",
                                  "description": "Negative for money out."
                                },
                                "currency": {
                                  "type": "string"
                                },
                                "direction": {
                                  "type": "string",
                                  "enum": ["in", "out"]
                                },
                                "source": {
                                  "type": "string",
                                  "enum": ["transfer", "card"]
                                },
                                "category": {
                                  "type": "string"
                                },
                                "status": {
                                  "type": "string"
                                },
                                "merchant": {
                                  "type": "string",
                                  "description": "Card movements."
                                },
                                "counterparty": {
                                  "type": "string",
                                  "description": "Transfers."
                                }
                              }
                            }
                          }
                        }
                      }
                    },
                    "totals": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "currency": {
                            "type": "string"
                          },
                          "available_minor": {
                            "type": "integer"
                          },
                          "booked_minor": {
                            "type": "integer"
                          },
                          "accounts": {
                            "type": "integer"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "recent out of range"
          },
          "401": {
            "description": "Not authenticated"
          },
          "403": {
            "description": "Not a customer JWT"
          }
        }
      }
    },
    "/api/v1/card-rules": {
      "get": {
        "operationId": "listCardRules",
        "tags": ["Cards"],
        "summary": "List card rules with card_count",
        "description": "BR-FM-010. A customer JWT lists its own rules. Service and admin\ncallers may filter with `customer_id`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "customer_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Rules",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "rules": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CardRule"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      },
      "post": {
        "operationId": "createCardRule",
        "tags": ["Cards"],
        "summary": "Create a card rule",
        "description": "Owned by the JWT customer. Service and admin callers pass\n`customer_id`. `name` and `currency` are required; the switches\n`online`, `contactless` and `atm` default to true, limits to none.\nLimits must keep daily <= monthly <= yearly where set (400\n`invalid_rule`).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/ScaToken"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CardRuleInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CardRule"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/api/v1/card-rules/{ruleId}": {
      "parameters": [
        {
          "name": "ruleId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "get": {
        "operationId": "getCardRule",
        "tags": ["Cards"],
        "summary": "Get a card rule",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Rule",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CardRule"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "put": {
        "operationId": "updateCardRule",
        "tags": ["Cards"],
        "summary": "Edit a card rule",
        "description": "Partial: omitted keys keep their value, `null` removes a limit.\nEvery card on the rule follows at once. Any currency is allowed,\nalso while cards use the rule (limits are evaluated in the rule's\ncurrency). A result that breaks daily <= monthly <= yearly is\nrefused (400 `invalid_rule`).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/ScaToken"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CardRuleInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Rule",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CardRule"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "delete": {
        "operationId": "deleteCardRule",
        "tags": ["Cards"],
        "summary": "Delete a card rule",
        "description": "Refused with 409 `rule_in_use` while a card that is not terminated\nor expired uses the rule. Terminated or expired cards keep the\nrule's values as custom values.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/ScaToken"
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deleted": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          }
        }
      }
    },
    "/api/v1/customers/{customerId}/cards/request": {
      "post": {
        "operationId": "requestCard",
        "tags": ["Cards"],
        "summary": "Request a new card (customer JWT)",
        "description": "Queues the CardIssuance workflow. `wallet_id` (or legacy `walletId`)\nand optional `currency` pick the account; default is the wallet's\nmain account (its own currency).\n\nCard settings are optional, first match wins: `rule_id` (one of\nthe customer's rules, any currency), `rule` (inline, validated and\nthen saved as a rule of the customer), or `limits` (same shape,\napplied to this card only; `rule_id` stays null). None of them: no\nlimits, all switches on. The inline rule is deleted again when the\nworkflow cannot be queued (503).\n\nWhat the card then shows (GET /api/v1/cards): with `rule_id` or\n`rule`, the card carries `rule_id` and `rule_name` and follows the\nrule. With `limits`, the card has its own `daily_limit`,\n`monthly_limit`, `yearly_limit`, `online`, `contactless` and `atm`\nand `rule_id` / `rule_name` are null: a template applied to this\ncard only is stored as values, not by name (`limits.name` is\nignored). A client that wants a name shown sends `rule`, or names\nthe card's own values itself (for example by matching them to its\ntemplates).\n\nIdempotency: send an `Idempotency-Key`. A retry with the same key\nand body returns the stored 202 (same `workflowKey`, same\n`rule_id`); the same key with another body is 409\n`idempotency_key_reused`; a request still running is 409\n`request_in_progress` with `Retry-After`. The workflow key is\nderived from the key (`card_{customerId}_{sha256(key)[0..16]}`), so\na retry after a lost reply reaches the same CardIssuance workflow\nand issues one card. Without the header the request runs as before\n(workflow key per second) and is logged.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "description": "Client key of this card request; reuse it on every retry."
          },
          {
            "$ref": "#/components/parameters/ScaToken"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["wallet_id", "cardType", "firstName", "lastName"],
                "properties": {
                  "wallet_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "currency": {
                    "type": "string",
                    "example": "EUR"
                  },
                  "cardType": {
                    "type": "string",
                    "enum": ["virtual", "physical"]
                  },
                  "firstName": {
                    "type": "string"
                  },
                  "lastName": {
                    "type": "string"
                  },
                  "label": {
                    "type": "string"
                  },
                  "rule_id": {
                    "type": "string",
                    "format": "uuid",
                    "nullable": true
                  },
                  "rule": {
                    "$ref": "#/components/schemas/CardRuleInput"
                  },
                  "limits": {
                    "$ref": "#/components/schemas/CardLimitsInput"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Queued",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "example": "queued"
                    },
                    "workflowKey": {
                      "type": "string"
                    },
                    "rule_id": {
                      "type": "string",
                      "format": "uuid",
                      "nullable": true
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`idempotency_key_reused` (the key was used for another body) or\n`request_in_progress` (retry after `Retry-After`).\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "The workflow dispatch was not confirmed\n(`card_issuance_unavailable`). An inline rule this request wrote\nis removed again only when Restate definitely refused the\ndispatch; when the answer was lost it is kept, since the card\nmay still be issued with it. Retry with the same\n`Idempotency-Key`: it reaches the same workflow and reuses the\nsame inline rule (its id derives from the key). Or poll GET\n/api/v1/cards first.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/cards": {
      "get": {
        "operationId": "listCards",
        "tags": ["Cards"],
        "summary": "List cards (one page of the request's bank, filtered and sorted)",
        "description": "One page of the cards of the request's bank (staff inside a cell:\nthe session's bank; the platform scope: `X-Tenant-ID`, else every\nbank). Filters, search, sort and paging run over every matching\ncard and `total` counts them (Core-Bank UX review 2026-10-07);\nevery statement names the request's bank besides row-level\nsecurity. Optionally filter by `customer_id`. A customer JWT sees\nonly its own cards; another `customer_id` is 403 `forbidden`\n(BR-FM-010).\nReturns card metadata stored in the database (no PAN/CVV \u2014 those live\nin the card network only, per PCI compliance), with the customer's\nname, the funding account's name and IBAN, and when the card was\nlast used.\nA bad filter is 400 `invalid_filter`; a failed read is 503\n`cards_unavailable`, never an empty list.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "customer_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Filter cards by customer ID"
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "unactivated",
                "active",
                "suspended",
                "terminated",
                "expired"
              ]
            }
          },
          {
            "name": "card_type",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": ["virtual", "physical"]
            }
          },
          {
            "name": "expiring_within_days",
            "in": "query",
            "description": "Cards still in use whose validity ends within this many days (1-366), already ended included.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 366
            }
          },
          {
            "name": "q",
            "in": "query",
            "description": "Text in the last four digits, cardholder, label or customer name (percent-decoded, at most 100 characters; `%` and `_` are literal).",
            "schema": {
              "type": "string",
              "maxLength": 100
            }
          },
          {
            "name": "sort",
            "in": "query",
            "description": "`created` (default, newest first), `expiry`, `cardholder`, `customer`, `status` (A to Z by default) or `last_used` (newest first).",
            "schema": {
              "type": "string",
              "enum": [
                "created",
                "expiry",
                "cardholder",
                "customer",
                "status",
                "last_used"
              ]
            }
          },
          {
            "name": "dir",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": ["asc", "desc"]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 200
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100000,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Card list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "cards": {
                      "type": "array",
                      "items": {
                        "allOf": [
                          {
                            "$ref": "#/components/schemas/Card"
                          },
                          {
                            "type": "object",
                            "properties": {
                              "customer_name": {
                                "type": "string"
                              },
                              "customer_type": {
                                "type": "string"
                              },
                              "account_name": {
                                "type": "string",
                                "nullable": true,
                                "description": "Name of the funding customer account."
                              },
                              "account_iban": {
                                "type": "string",
                                "nullable": true
                              },
                              "last_used_at": {
                                "type": "string",
                                "format": "date-time",
                                "nullable": true,
                                "description": "The card's latest authorization."
                              }
                            }
                          }
                        ]
                      }
                    },
                    "total": {
                      "type": "integer",
                      "description": "Every card the filters match."
                    },
                    "limit": {
                      "type": "integer"
                    },
                    "offset": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`invalid_filter`: a filter, sort or page value that is not allowed."
          },
          "503": {
            "description": "`cards_unavailable`: the list could not be read; try again."
          }
        }
      },
      "post": {
        "operationId": "createCard",
        "tags": ["Cards"],
        "summary": "Create card record (internal, called by workflow engine)",
        "description": "Stores card metadata in the database after the card issuance\nworkflow has created the card in the card network. Not called directly by\nadmin UI \u2014 use the workflow engine endpoint instead.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCardRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Card record created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Card"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/cards/{cardId}": {
      "get": {
        "operationId": "getCard",
        "tags": ["Cards"],
        "summary": "Get card by ID",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CardId"
          }
        ],
        "responses": {
          "200": {
            "description": "Card details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Card"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/cards/{cardId}/status": {
      "patch": {
        "operationId": "updateCardStatus",
        "tags": ["Cards"],
        "summary": "Update card status (reactivate)",
        "description": "Updates the card status. Currently used to reactivate a suspended card\n(set `status` to `active`). For suspend and terminate, use the dedicated\nPOST endpoints which enforce state machine rules.\n\nCustomer callers (JWT): unfreeze is `suspended` -> `active` and only\nfor a suspension the customer placed (`suspended_by` `customer`);\na bank suspension is 403 `suspended_by_bank`. A card that was never\nactive (`unactivated`) is not activated here: 409\n`card_not_activatable`. A customer freezes only an active card\n(409 `card_not_active` otherwise). Terminated and expired cards are\n403. Staff sessions and service keys keep their rights.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CardId"
          },
          {
            "$ref": "#/components/parameters/ScaToken"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["status"],
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": ["active"]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Card status updated"
          },
          "403": {
            "description": "`forbidden` (terminated or expired card) or `suspended_by_bank`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "`card_not_activatable`: the card was never active",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/cards/{cardId}/suspend": {
      "post": {
        "operationId": "suspendCard",
        "tags": ["Cards"],
        "summary": "Suspend card (ACTIVE -> SUSPENDED)",
        "description": "Temporarily suspends the card. All authorization attempts will be\ndeclined by the JIT gateway. The card can be reactivated via\n`PATCH /api/v1/cards/{cardId}/status`. A customer caller may suspend\nonly an active card (409 `card_not_active` otherwise).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CardId"
          },
          {
            "$ref": "#/components/parameters/ScaToken"
          }
        ],
        "responses": {
          "200": {
            "description": "Card suspended"
          },
          "409": {
            "description": "`card_not_active`: a customer cannot suspend a card that is not active",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/cards/{cardId}/lifecycle/{action}": {
      "post": {
        "operationId": "staffCardLifecycle",
        "tags": ["Cards"],
        "summary": "Staff card lifecycle change (the bank's decision)",
        "description": "A staff session changes a card of its bank through Restate\nCardLifecycle, named as the session's officer (security review M1,\n2026-10-07). `suspend` and `lost-stolen`: `bank_admin`,\n`bank_staff`, `mlro`; `reactivate`, `terminate`, `reissue`:\n`bank_admin`. The platform `super_admin` reads and gets 403\n`platform_read_only`. The card must be the bank's (404\n`card_not_found`) and in a status the action starts from (409\n`invalid_card_status`). The workflow's answer is returned as\n`result`; a workflow failure is 502 `card_lifecycle_failed`.\n`Idempotency-Key` (one per submit, final review M1): a retry with the\nsame key attaches to the first run. The request's audit row is\ncommitted before the workflow runs.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CardId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "name": "action",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "suspend",
                "lost-stolen",
                "reactivate",
                "terminate",
                "reissue"
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["reason"],
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 10,
                    "maxLength": 1000
                  },
                  "per_transaction_limit": {
                    "type": "integer",
                    "minimum": 0,
                    "description": "reissue only, minor units"
                  },
                  "daily_limit": {
                    "type": "integer",
                    "minimum": 0,
                    "description": "reissue only, minor units"
                  },
                  "monthly_limit": {
                    "type": "integer",
                    "minimum": 0,
                    "description": "reissue only, minor units"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The workflow's answer",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "result": {
                      "type": "object",
                      "additionalProperties": true
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`reason_required`, `invalid_json`, `invalid_limit`, `idempotency_key_required`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "404": {
            "description": "`card_not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "`invalid_card_status`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "`card_lifecycle_failed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/cards/issuance": {
      "post": {
        "operationId": "staffIssueCard",
        "tags": ["Cards"],
        "summary": "Issue a card for a customer of the bank",
        "description": "Runs Restate CardIssuance for a customer of the session's bank and an\naccount the customer holds (404 `account_not_found` otherwise),\nnamed as the session's officer (security review M1, 2026-10-07). The\nbank's `mlro`, or the platform `super_admin` on the bank's behalf\nwith `X-Tenant-ID` and a reason (see \"Platform assist\").\n`Idempotency-Key` (one per submit, final review M1): the workflow key\nis derived from the bank and the key, so a retry answers the first\nrun's card, never a second card (400 `idempotency_key_required`\nwithout it).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/ChangeReason"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "customer_id",
                  "account_id",
                  "card_type",
                  "cardholder_name",
                  "first_name",
                  "last_name"
                ],
                "properties": {
                  "customer_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "account_id": {
                    "type": "string",
                    "maxLength": 64
                  },
                  "tenant_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "must be the bank of the request"
                  },
                  "card_type": {
                    "type": "string",
                    "enum": ["virtual", "physical"]
                  },
                  "cardholder_name": {
                    "type": "string"
                  },
                  "first_name": {
                    "type": "string"
                  },
                  "last_name": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string"
                  },
                  "label": {
                    "type": "string"
                  },
                  "country": {
                    "type": "string"
                  },
                  "per_transaction_limit": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "daily_limit": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "monthly_limit": {
                    "type": "integer",
                    "minimum": 0
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The workflow's answer (the new card)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "result": {
                      "type": "object",
                      "additionalProperties": true
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/PlatformAssistRefused"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "404": {
            "description": "`account_not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "`card_lifecycle_failed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/cards/{cardId}/terminate": {
      "post": {
        "operationId": "terminateCard",
        "tags": ["Cards"],
        "summary": "Terminate card permanently (irreversible)",
        "description": "Permanently terminates the card. This is irreversible \u2014 terminated\ncards cannot be reactivated. Any pending authorization holds on the\nlinked ledger account are voided. A replacement card must be\nissued via the card issuance workflow.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CardId"
          },
          {
            "$ref": "#/components/parameters/ScaToken"
          }
        ],
        "responses": {
          "200": {
            "description": "Card terminated"
          }
        }
      }
    },
    "/api/v1/cards/{cardId}/limits": {
      "patch": {
        "operationId": "updateCardLimits",
        "tags": ["Cards"],
        "summary": "Update card spending limits",
        "description": "Partial update (BR-FM-010): omitted keys keep their value, `null`\nremoves a limit. Takes `daily_limit`, `monthly_limit`,\n`yearly_limit` and the switches `online`, `contactless`, `atm`;\nmissing switches stay unchanged. Limits are minor units of the card's\n`limits_currency` (0 means no limit and is stored as null), must keep daily\n<= monthly <= yearly after the merge, and are enforced by the JIT\nfunding gateway. `per_transaction_limit: null` is accepted and\nignored (it is not part of card settings); a number sets the card's\nown per-transaction limit and 0 clears it (portal).\n\nA card on a rule becomes custom (`rule_id` null) and starts from the\nrule's values. A customer JWT may only edit its own cards (403\n`forbidden`). Invalid values: 400 `invalid_rule`.\n\n`limits_currency` (optional, a code of the currency registry, any\ncase) is the currency the amounts in this body are in; it is stored\nas the card's own limits currency. Absent or null keeps the stored\none (a card leaving a rule takes the rule's). Another currency than\nthe card's current `limits_currency` needs `daily_limit`,\n`monthly_limit` and `yearly_limit` in the same body (else 400\n`invalid_rule`). It does not change the currency of\n`per_transaction_limit`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CardId"
          },
          {
            "$ref": "#/components/parameters/ScaToken"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "per_transaction_limit": {
                    "type": "integer",
                    "nullable": true,
                    "description": "null is ignored; a number sets the card's own per-transaction limit, 0 clears it"
                  },
                  "daily_limit": {
                    "type": "integer",
                    "nullable": true,
                    "minimum": 0,
                    "description": "Daily spending limit in minor units"
                  },
                  "monthly_limit": {
                    "type": "integer",
                    "nullable": true,
                    "minimum": 0,
                    "description": "Monthly spending limit in minor units"
                  },
                  "yearly_limit": {
                    "type": "integer",
                    "nullable": true,
                    "minimum": 0,
                    "description": "Yearly (calendar year) spending limit in minor units"
                  },
                  "online": {
                    "type": "boolean",
                    "description": "Card-not-present (e-commerce, MOTO)"
                  },
                  "contactless": {
                    "type": "boolean"
                  },
                  "atm": {
                    "type": "boolean",
                    "description": "Cash withdrawal (ATM, MCC 6011)"
                  },
                  "limits_currency": {
                    "type": "string",
                    "nullable": true,
                    "example": "EUR",
                    "description": "ISO 4217 code of the currency registry; the currency of the limit amounts, stored as the card's own. Absent or null keeps the stored one."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Limits updated; the card, now custom",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Card"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/cards/{cardId}/rule": {
      "post": {
        "operationId": "setCardRule",
        "tags": ["Cards"],
        "summary": "Put a card on a rule, or make it custom",
        "description": "BR-FM-010. `{\"rule_id\":\"<uuid>\"}` puts the card on one of its\ncustomer's rules, in any currency: the JIT gateway converts each\nauthorization into the rule's currency. `{\"rule_id\":null}` makes the card\ncustom, starting from the rule's values. Customer JWTs act on their\nown cards only.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CardId"
          },
          {
            "$ref": "#/components/parameters/ScaToken"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["rule_id"],
                "properties": {
                  "rule_id": {
                    "type": "string",
                    "format": "uuid",
                    "nullable": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The card",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Card"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/cards/{cardId}/account": {
      "patch": {
        "operationId": "changeCardAccount",
        "tags": ["Cards"],
        "summary": "Move a card to another funding account",
        "description": "SF-finance-api-card-funding-account. `account_id` is a ledger\naccount id the phone knows (the card's `account_id`, or\n`account_ids[].tb_id` of a wallet) or a wallet id (the wallet's main\naccount: the entry in the wallet's currency, else the first). The\naccount must belong to the card's customer in the card's tenant and\nbe active (wallet active; ledger account not frozen, closing, closed\nor written off).\n\nThe card's `account_id`, `wallet_id` and `currency` follow the\naccount. Limits keep their currency (`limits_currency`): a card\nwhose limits were EUR 500 a month keeps EUR 500 when it moves to a\nUSD account. The JIT gateway converts each authorization into the\nnew account's currency. Setting the same account again answers 200\nwith the card and changes nothing. A change is written to the audit\nlog (event 804 `CARD_ACCOUNT_CHANGED`).\n\nCustomer JWTs act on their own cards only and need `X-SCA-Token`\n(403 `SCA required` / `Invalid SCA token`). Errors: 400\n`invalid_body`, 403 `forbidden`, 404 `not_found` (card) or\n`account_not_found`, 409 `card_not_active` (terminated, cancelled or\nexpired card) or `account_not_active`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CardId"
          },
          {
            "$ref": "#/components/parameters/ScaToken"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["account_id"],
                "properties": {
                  "account_id": {
                    "type": "string",
                    "maxLength": 64,
                    "pattern": "^[0-9A-Fa-f-]+$",
                    "description": "Ledger account id (tb_id) or wallet id",
                    "example": "10000000000000000000000000000032"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The card, now spending from the account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Card"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          }
        }
      }
    },
    "/api/v1/cards/{cardId}/history": {
      "get": {
        "operationId": "getCardHistory",
        "tags": ["Cards"],
        "summary": "What happened to a card (staff)",
        "description": "Newest first, at most 100 entries: the officers' lifecycle actions\nas Core-Bank records them (issue, suspend, reactivate, terminate,\nreissue, lost or stolen, limit change; `source` `officer`, with the\nofficer's email, role and reason) and the status changes\nfinance-api audits itself (`source` `system`: activated,\nsuspended, terminated, account_changed, with `actor_kind`\ncustomer, officer or system and the statuses before and after).\nRows of the card's own bank only. Staff and services; a customer\ncaller is 403 `forbidden`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CardId"
          }
        ],
        "responses": {
          "200": {
            "description": "The card's history",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "entries": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "source": {
                            "type": "string",
                            "enum": ["officer", "system"]
                          },
                          "action": {
                            "type": "string",
                            "description": "officer: CARD_ISSUED, CARD_SUSPENDED, CARD_REACTIVATED, CARD_TERMINATED, CARD_REISSUED, CARD_LOST_STOLEN, CARD_LIMIT_CHANGED; system: activated, suspended, terminated, account_changed"
                          },
                          "actor_kind": {
                            "type": "string",
                            "enum": ["officer", "customer", "system"]
                          },
                          "actor_email": {
                            "type": "string"
                          },
                          "actor_role": {
                            "type": "string"
                          },
                          "reason": {
                            "type": "string"
                          },
                          "from_status": {
                            "type": "string"
                          },
                          "to_status": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "503": {
            "description": "`history_unavailable`: try again."
          }
        }
      }
    },
    "/api/v1/cards/{cardId}/transactions": {
      "get": {
        "operationId": "listCardTransactions",
        "tags": ["Cards"],
        "summary": "List card authorizations/transactions",
        "description": "Returns the authorization records of the card. Includes status\n(authorized, settled, reversed, declined, expired, disputed),\nmerchant info, amounts, and ledger hold references. Filters:\n`direction` (every authorization is `out`), `from`, `to`,\n`status`, `currency`, `q` (merchant name). `account_id`,\n`event_type` and `q_type` are 400 `invalid_filter` here.\n\nKeyset paging (DEC-0029): newest first, `created_at` descending then\nthe row id descending. Follow `next_cursor` while `has_more` is\ntrue; a page never skips or repeats a row, also when rows share\n`created_at`. A filter change starts from the first page.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CardId"
          },
          {
            "$ref": "#/components/parameters/HistoryLimit"
          },
          {
            "$ref": "#/components/parameters/HistoryCursor"
          },
          {
            "$ref": "#/components/parameters/HistoryDirection"
          },
          {
            "$ref": "#/components/parameters/HistoryFrom"
          },
          {
            "$ref": "#/components/parameters/HistoryTo"
          },
          {
            "$ref": "#/components/parameters/HistoryTzOffset"
          },
          {
            "$ref": "#/components/parameters/HistoryStatus"
          },
          {
            "$ref": "#/components/parameters/HistoryCurrency"
          },
          {
            "$ref": "#/components/parameters/HistoryQuery"
          },
          {
            "$ref": "#/components/parameters/HistoryAmountMin"
          },
          {
            "$ref": "#/components/parameters/HistoryAmountMax"
          }
        ],
        "responses": {
          "200": {
            "description": "One page of the authorization list",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/HistoryPage"
                    },
                    {
                      "type": "object",
                      "required": ["authorizations"],
                      "properties": {
                        "authorizations": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/CardAuthorization"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HistoryBadRequest"
          },
          "422": {
            "$ref": "#/components/responses/HistorySearchTooBroad"
          },
          "429": {
            "$ref": "#/components/responses/HistorySearchBusy"
          },
          "500": {
            "$ref": "#/components/responses/HistoryFailed"
          },
          "503": {
            "$ref": "#/components/responses/HistoryUnavailable"
          }
        }
      }
    },
    "/api/v1/cards/{cardId}/label": {
      "patch": {
        "operationId": "updateCardLabel",
        "tags": ["Cards"],
        "summary": "Rename card label",
        "description": "Updates the user-facing label of a card. This is a cosmetic change\nonly and does not affect card network state or authorization behavior.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CardId"
          },
          {
            "$ref": "#/components/parameters/ScaToken"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["label"],
                "properties": {
                  "label": {
                    "type": "string",
                    "maxLength": 50
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Label updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Card"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/cards/{cardId}/sensitive": {
      "get": {
        "operationId": "getCardSensitiveData",
        "tags": ["Cards"],
        "summary": "Retrieve sensitive card data (PAN, CVV, expiry)",
        "description": "Returns the full PAN, CVV2, and expiry date for the card. This\nendpoint is restricted to authenticated card owners and requires\nthe session to have explicit sensitive-data permissions. Data is\nfetched from the card network provider in real-time and never\nstored in the finance-api database.\n\nA customer JWT with member role `accounting` gets 403\n`{\"error\":\"forbidden_role\"}` and the provider is not called; an\nimpersonation session gets 403 `{\"error\":\"read_only_session\"}`\n(least privilege, DEC-0028). Masked card details stay readable.\n\n**PCI scope note:** This endpoint is PCI-scoped and only available\nwhere the card provider, licensing setup, and PCI control environment\nexplicitly permit sensitive data retrieval. Exclude from audit scope\nunless card issuance is explicitly in scope.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/CardId"
          },
          {
            "$ref": "#/components/parameters/ScaToken"
          }
        ],
        "responses": {
          "200": {
            "description": "Sensitive card data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "pan": {
                      "type": "string",
                      "description": "Full Primary Account Number"
                    },
                    "cvv": {
                      "type": "string",
                      "nullable": true,
                      "description": "CVV2 security code; null when the provider did not return it"
                    },
                    "cvv_available": {
                      "type": "boolean",
                      "description": "False when the provider did not return a CVV2"
                    },
                    "expiry_month": {
                      "type": "string",
                      "description": "Two digits, for example 09"
                    },
                    "expiry_year": {
                      "type": "string",
                      "description": "Two digits, for example 29"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/cards/authorizations/by-network-ref/{ref}": {
      "get": {
        "operationId": "getCardAuthByNetworkRef",
        "tags": ["Cards"],
        "summary": "Lookup authorization by network reference ID",
        "description": "Resolves an authorization record by its card network reference ID.\nUsed internally by the card settlement workflow service to link\nclearing/reversal events back to the original authorization.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Network reference ID from card scheme"
          }
        ],
        "responses": {
          "200": {
            "description": "Authorization details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CardAuthorization"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/cards/authorizations/update-status": {
      "post": {
        "operationId": "updateCardAuthStatus",
        "tags": ["Cards"],
        "summary": "Update authorization status (internal)",
        "description": "Updates the status and optional settled amount on an authorization\nrecord. Called by the card settlement workflow service after\nprocessing clearing, reversal, or chargeback events.\n\nThe status only moves forward (DEC-0041): authorized to any;\nexpired and reversed to settled or disputed; settled to disputed;\ndisputed to reversed only while not cleared (the parked\nchargebacks then go to ops review). `settled` on a disputed\nauthorization records `settled_amount` and keeps `disputed`. The\nsame status again is a replay. Anything else: 409\n`illegal_status_transition`, row unchanged.\n\nA `settled` update also applies the chargebacks parked before this\nclearing (see `POST /api/v1/cards/refund`), in the same transaction.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["auth_id", "status"],
                "properties": {
                  "auth_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "authorized",
                      "settled",
                      "reversed",
                      "declined",
                      "expired",
                      "disputed"
                    ]
                  },
                  "settled_amount": {
                    "type": "string",
                    "description": "Settled amount in minor units (string)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Authorization status updated (the row after the update)"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`illegal_status_transition`: the status cannot move there; `settled_amount_conflict`: a `settled_amount` other than the one already recorded (row unchanged in both)"
          }
        }
      }
    },
    "/api/v1/cards/holds/settle": {
      "post": {
        "operationId": "settleCardHold",
        "tags": ["Cards"],
        "summary": "Settle ledger pending hold (POST_PENDING_TRANSFER)",
        "description": "Finalizes a pending ledger hold created during JIT authorization.\nSupports partial settlement \u2014 if `amount` is less than the original\nhold, the remainder is automatically voided.\n\n`amount` is in network minor units (the currency the authorization\nconverted: the original merchant currency when Marqeta sent one,\nelse the billing currency). When the authorization was converted\ninto the funding account's currency, one linked ledger chain:\nposts the recorded `account_amount` (or the same share of it,\nrounded up, for a partial clearing) at the authorization rate;\nmoves the card FX fee part to the platform fee account; and books\nthe difference between the posted principal and the cleared amount\nat the clearing mid rate to the FX P&L account (`Platform FX <CCY>`,\naccount code platform_fx). The result is recorded on the\nauthorization (`settled_account_amount`, `settled_fee_amount`,\n`clearing_fx_rate`, `clearing_fx_diff`, positive = FX gain). Ids are\nderived from the hold, so a retry does not post twice. A clearing\nabove the authorization fails, as it does for a same-currency hold.\n\n`clearing_token` (the network clearing event) keys idempotency: a\nreplay of the same event answers from the ledger; another clearing\nevent for a hold that is already cleared is refused 409\n`clearing_already_posted` (multi-clearing is not supported; ops).\nA clearing after the hold expired debits the account with a plain\ntransfer (`\"late\":true`); refused by the ledger: 409\n`late_clearing_refused`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["hold_id"],
                "properties": {
                  "hold_id": {
                    "type": "string",
                    "description": "Hex-encoded ledger transfer ID"
                  },
                  "amount": {
                    "type": "integer",
                    "nullable": true,
                    "description": "Settlement amount in minor units; absent or null settles the whole hold; 0 or negative is 400"
                  },
                  "clearing_token": {
                    "type": "string",
                    "description": "Network clearing event token (idempotency key). Missing (workflow before the rollout): keyed on the hold, one clearing per hold"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Hold settled: `account_amount` posted, `fee_amount` to fees,\n`fx_diff` to the FX P&L account (converted holds)\n"
          },
          "400": {
            "description": "Missing or invalid hold_id, or amount not positive"
          },
          "409": {
            "description": "`clearing_already_posted` (another clearing event for a cleared hold) or `late_clearing_refused`"
          },
          "422": {
            "description": "Settlement failed (hold not found or already settled, or a direct debit credit held until its holding period ends, also for the platform caller; same body)"
          }
        }
      }
    },
    "/api/v1/cards/holds/void": {
      "post": {
        "operationId": "voidCardHold",
        "tags": ["Cards"],
        "summary": "Void ledger pending hold (VOID_PENDING_TRANSFER)",
        "description": "Releases a pending ledger hold entirely. Used for authorization\nreversals when the merchant cancels the transaction before settlement.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["hold_id"],
                "properties": {
                  "hold_id": {
                    "type": "string",
                    "description": "Hex-encoded ledger transfer ID"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Hold voided"
          },
          "422": {
            "description": "Void failed (hold not found or already settled, or a direct debit credit held until its holding period ends, also for the platform caller; same body)"
          }
        }
      }
    },
    "/api/v1/cards/refund": {
      "post": {
        "operationId": "processCardRefund",
        "tags": ["Cards"],
        "summary": "Credit a card refund or chargeback",
        "description": "Credits a network refund or chargeback of a cleared card purchase\n(card settlement workflow). Internal callers only. Chargebacks:\nDEC-0041.\n\n- **Account:** the account the authorization debited\n  (`funding_account_id`, or the debit side of the hold for older\n  rows), never the card's current account.\n- **Rate:** the mid rate at refund time into that account's\n  currency. The difference against the authorization rate is booked\n  to the FX P&L account and stored (`fx_diff`, positive = gain).\n  Across currencies the chain is card suspense (network) -> Master\n  (network); Master (account) -> account; FX difference between\n  Master (account) and FX P&L; all linked.\n- **Cap:** what the ledger posted for the purchase's clearing (bounded\n  by `settled_amount`), minus what refunds and chargebacks already\n  credited. A refund above it: 409 `refund_exceeds_cleared`; no\n  clearing in the ledger: 409 `refund_not_cleared`. Holds resolved\n  before deterministic post ids (2026-09-28) cap at `settled_amount`\n  once the hold has lapsed.\n- **Chargebacks** (`kind: chargeback`) credit only for\n  `event_type` `authorization.clearing.chargeback`,\n  `.chargeback.provisional.credit` or `.chargeback.completed` with\n  `credit_user: true`, once per authorization. Never a void.\n  - Purchase not cleared in our ledger yet: **202** `parked`\n    (`reason: not_cleared`); applied after the clearing (a `settled`\n    status update, `kind: chargeback_apply`, or the hourly sweeper).\n  - No money moves, kept for ops: **200** `ops_review` with `reason`\n    `debit_back_not_supported` (reversal, provisional debit,\n    representment), `writeoff_not_supported`,\n    `unknown_chargeback_type`, `not_a_chargeback`,\n    `event_type_missing`, `credit_user_not_true`, `second_credit`,\n    `exceeds_cleared` (a chargeback is never answered 409 for the\n    cap), `no_hold` and `authorization_reversed` (no clearing can\n    come: no hold, or our void exists), `parked_expired` (parked\n    longer than 30 days, set by the sweeper).\n  - `kind: chargeback_record` never moves money (`ops_review`).\n  - `kind: chargeback_apply` takes only `original_network_ref` and\n    `card_token`: applies the oldest parked chargeback of the\n    purchase (answers as above) or `{\"status\":\"none\"}`.\n- **Idempotent** by `network_token`: a replay answers with the\n  stored result (`replay: true`) and posts nothing new.\n- **Currency:** the amount in the authorization's currency is used:\n  `amount`/`currency` (billing) or `original_amount` /\n  `original_currency` (merchant side, when the authorization\n  converted the original); otherwise 409 `refund_currency_mismatch`.\n- Unknown purchase or another card's: 409 `refund_unmatched`.\n- Audit event 813 (`card.refund_credit` / `card.chargeback_credit`;\n  `card.chargeback_parked` / `card.chargeback_ops_review` when no\n  money moved).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["card_token", "original_network_ref"],
                "properties": {
                  "card_token": {
                    "type": "string",
                    "description": "Card network provider token"
                  },
                  "amount": {
                    "type": "integer",
                    "description": "Refund amount in minor units of currency"
                  },
                  "currency": {
                    "type": "string",
                    "description": "Billing currency (ISO 4217 alpha or numeric)",
                    "example": "EUR"
                  },
                  "original_amount": {
                    "type": "integer",
                    "description": "Merchant-side amount in minor units of original_currency"
                  },
                  "original_currency": {
                    "type": "string",
                    "example": "USD"
                  },
                  "reference": {
                    "type": "string",
                    "description": "Refund reference (e.g. REFUND-{event_token})"
                  },
                  "network_token": {
                    "type": "string",
                    "description": "Network event token; idempotency key (defaults to reference)"
                  },
                  "kind": {
                    "type": "string",
                    "enum": [
                      "refund",
                      "chargeback",
                      "chargeback_record",
                      "chargeback_apply"
                    ],
                    "description": "Required except for chargeback_apply: amount, network_token or reference"
                  },
                  "event_type": {
                    "type": "string",
                    "description": "Marqeta transaction type of a chargeback",
                    "example": "authorization.clearing.chargeback"
                  },
                  "credit_user": {
                    "type": "boolean",
                    "description": "Marqeta credit_user of a chargeback; only true may credit"
                  },
                  "original_network_ref": {
                    "type": "string",
                    "description": "Network reference of the purchase being refunded"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Credited (`refunded`), a chargeback kept for ops without money (`ops_review`, with `reason`), or nothing parked to apply (`none`)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": ["refunded", "ops_review", "none"]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Why no money moved (ops_review)"
                    },
                    "kind": {
                      "type": "string",
                      "enum": ["refund", "chargeback"]
                    },
                    "replay": {
                      "type": "boolean"
                    },
                    "account_id": {
                      "type": "string"
                    },
                    "account_amount": {
                      "type": "integer"
                    },
                    "account_currency": {
                      "type": "string"
                    },
                    "network_amount": {
                      "type": "integer"
                    },
                    "network_currency": {
                      "type": "string"
                    },
                    "fx_rate": {
                      "type": "string"
                    },
                    "fx_rate_source": {
                      "type": "string",
                      "enum": ["live", "fallback", "none"]
                    },
                    "fx_diff": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "202": {
            "description": "Chargeback parked: the purchase is not cleared in our ledger yet (`status: parked`, `reason: not_cleared`); applied after the clearing",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": ["parked"]
                    },
                    "reason": {
                      "type": "string",
                      "enum": ["not_cleared"]
                    },
                    "replay": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`refund_not_cleared`, `refund_exceeds_cleared` (refunds only), `refund_currency_mismatch`, `refund_unmatched`, `refund_account_not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "enum": [
                        "refund_not_cleared",
                        "refund_exceeds_cleared",
                        "refund_currency_mismatch",
                        "refund_unmatched",
                        "refund_account_not_found"
                      ]
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "No FX rate, Master account or ledger available (`fx_unavailable`, `nostro_unavailable`, `ledger_unavailable`), or the commit was lost (`refund_not_committed`, `chargeback_not_committed`); retry"
          }
        }
      }
    },
    "/api/v1/cards/reconciliation": {
      "get": {
        "operationId": "cardReconciliation",
        "tags": ["Cards"],
        "summary": "Card FX reconciliation (auth vs clearing vs refunds)",
        "description": "Ops report per card authorization (newest first, 500 at most): the\nauthorization (network amount and currency, amount source, billing\nside, account debited, held account amount, rate and rate source,\nFX fee), the clearing (cleared network amount, posted account\namount, fee part, clearing rate, FX result) and the refunds (count,\nnetwork and account totals, FX result), plus `fx_result`, the total\nFX gain (positive) or loss (negative) in account minor units.\nInternal callers only.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "card_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Reconciliation rows",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "transactions": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": true
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/api/v1/marqeta/jit-gateway": {
      "post": {
        "operationId": "marqetaJitGateway",
        "tags": ["CardGateway"],
        "summary": "JIT Funding Gateway (card network provider -> Isaac)",
        "description": "Real-time authorization decision endpoint. The card network provider\nsends POST requests here when a cardholder swipes their card.\nMust respond within 2 seconds.\n\n**Flow:** Verify Basic Auth -> Parse transaction -> Lookup card in DB ->\nCheck MCC restrictions -> Check online/contactless/ATM switches ->\nCheck geo restriction -> Lookup the funding account in the ledger ->\nConvert the amount into the account currency -> Check spending\nlimits (per-tx; daily, monthly and yearly, the rule's when the card\nis on one) in the limits' own currency -> Check ledger balance ->\nCreate ledger pending hold -> Store authorization record in DB ->\nRespond HTTP 200 (approve) or HTTP 402 (decline).\n\n**Currency:** the card only chooses which account pays; the\nMarqeta card product is never changed. When Marqeta sends the\nmerchant's original amount (`currency_conversion.network.\noriginal_amount` / `original_currency_code`, alpha or ISO numeric),\nthat amount is converted ONCE into the funding account's currency;\notherwise `amount` in `currency_code` (billing). Amounts use the\ncurrency's exponent (JPY 0, EUR 2, KWD 3). The conversion uses the\nFX mid rate the app quotes with, rounded up, plus the card FX fee\nof the tenant's (or customer's) active `card_fx` fee schedule in the\naccount currency (none = no fee), before the balance check and the\nhold. A static fallback rate is allowed only up to the tenant's\ncap (`/api/v1/limits/card-fx`, default EUR 100.00); above it, or\nwith no rate at all, the decline is `FX_UNAVAILABLE` and nothing is\nheld. The authorization records `amount_source`, `fx_rate_source`,\nthe billing side and the account debited. Limits stay in\n`limits_currency` (a rule's currency, any currency allowed) and the\ncard's own per-transaction limit in `per_transaction_limit_currency`;\nspend is counted in them (the FX fee is not spend). The response\nechoes the billing amount and currency.\n\n**Decline memos:** INVALID_REQUEST, INVALID_AMOUNT, ZERO_AMOUNT,\nINVALID_CARD, CARD_NOT_FOUND, CARD_NOT_ACTIVE, MCC_BLOCKED,\nONLINE_BLOCKED, CONTACTLESS_BLOCKED, ATM_BLOCKED, GEO_BLOCKED,\nNO_ACCOUNT, INVALID_ACCOUNT, ACCOUNT_NOT_FOUND, FX_UNAVAILABLE,\nPER_TRANSACTION_LIMIT_EXCEEDED, DAILY_LIMIT_EXCEEDED,\nMONTHLY_LIMIT_EXCEEDED, YEARLY_LIMIT_EXCEEDED, INSUFFICIENT_FUNDS,\nSYSTEM_ERROR.\n\nAuthentication uses HTTP Basic Auth with credentials separate from\nthe webhook endpoint.\n",
        "security": [
          {
            "BasicAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "example": "authorization"
                  },
                  "state": {
                    "type": "string",
                    "example": "PENDING"
                  },
                  "token": {
                    "type": "string",
                    "description": "Card network transaction token"
                  },
                  "card_token": {
                    "type": "string"
                  },
                  "user_token": {
                    "type": "string"
                  },
                  "amount": {
                    "type": "number",
                    "description": "Amount in major units of currency_code (e.g. 10.00)"
                  },
                  "currency_code": {
                    "type": "string",
                    "example": "EUR",
                    "description": "Network (card product billing) currency; empty means the account currency"
                  },
                  "currency_conversion": {
                    "type": "object",
                    "properties": {
                      "network": {
                        "type": "object",
                        "properties": {
                          "original_amount": {
                            "type": "number",
                            "description": "Merchant amount in major units of original_currency_code"
                          },
                          "original_currency_code": {
                            "type": "string",
                            "description": "Alpha (USD) or ISO numeric (840)"
                          },
                          "conversion_rate": {
                            "type": "number"
                          }
                        }
                      }
                    }
                  },
                  "merchant": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string"
                      },
                      "mcc": {
                        "type": "string"
                      },
                      "city": {
                        "type": "string"
                      },
                      "country": {
                        "type": "string"
                      }
                    }
                  },
                  "network_reference_id": {
                    "type": "string"
                  },
                  "jit_funding": {
                    "type": "object",
                    "properties": {
                      "token": {
                        "type": "string"
                      },
                      "method": {
                        "type": "string",
                        "example": "pgfs.authorization"
                      },
                      "amount": {
                        "type": "number"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Authorization approved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "jit_funding": {
                      "type": "object",
                      "properties": {
                        "token": {
                          "type": "string"
                        },
                        "method": {
                          "type": "string"
                        },
                        "amount": {
                          "type": "number"
                        },
                        "currency_code": {
                          "type": "string"
                        },
                        "memo": {
                          "type": "string",
                          "example": "Approved"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "Authorization declined",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "jit_funding": {
                      "type": "object",
                      "properties": {
                        "token": {
                          "type": "string"
                        },
                        "method": {
                          "type": "string"
                        },
                        "amount": {
                          "type": "number",
                          "example": 0
                        },
                        "currency_code": {
                          "type": "string"
                        },
                        "memo": {
                          "type": "string",
                          "example": "INSUFFICIENT_FUNDS",
                          "description": "Decline reason (see the list above), e.g. FX_UNAVAILABLE"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/marqeta/webhooks": {
      "post": {
        "operationId": "marqetaWebhook",
        "tags": ["CardGateway"],
        "summary": "Webhook event receiver (card network provider -> Isaac)",
        "description": "Receives async webhook notifications from the card network provider\nfor transaction lifecycle events. Always responds HTTP 200 to\nacknowledge receipt (the provider retries on non-200).\n\n**Event routing:**\n- `authorization.clearing` -> workflow engine `CardSettlement/process_clearing`\n- `authorization.reversal` -> workflow engine `CardSettlement/process_reversal`\n- `refund` -> workflow engine `CardSettlement/process_refund`\n- `card.*` -> Direct DB update (card status transition)\n- `authorization` -> Informational log (JIT already handled)\n\n**Idempotency:** Events are deduplicated via `event_token` UNIQUE\nconstraint in `finance_card_event`. Duplicate deliveries are logged\nand acknowledged without re-processing.\n",
        "security": [
          {
            "BasicAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "description": "Event type (e.g. authorization.clearing)"
                  },
                  "token": {
                    "type": "string",
                    "description": "Transaction token"
                  },
                  "event_token": {
                    "type": "string",
                    "description": "Unique event token for idempotency"
                  },
                  "card_token": {
                    "type": "string"
                  },
                  "user_token": {
                    "type": "string"
                  },
                  "amount": {
                    "type": "number"
                  },
                  "currency_code": {
                    "type": "string"
                  },
                  "network_reference_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event acknowledged"
          }
        }
      }
    },
    "/api/v1/cash-deposits": {
      "post": {
        "operationId": "createCashDeposit",
        "tags": ["Cash Deposits"],
        "summary": "Create a branch cash deposit with AML compliance checks",
        "description": "Records a cash deposit at a bank branch. The system automatically\nperforms AML compliance checks including daily aggregate calculation,\nstructuring detection, and source-of-funds validation. Thresholds are\nEUR amounts of the bank's jurisdiction profile (default EUR 10,000 a\nday, EUR 15,000 for one deposit; migration 268): every deposit is\ncompared by its EUR equivalent at the reference rate, whatever its\ncurrency. Deposits under the daily threshold are auto-approved; those\nreaching it are flagged for a second officer and need the source of\nfunds. A currency without a reference rate is 422\n`fx_rate_unavailable` and nothing is recorded.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCashDepositRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Deposit created (auto-approved or flagged for review)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CashDepositCreateResult"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "description": "Compliance validation failed (KYC not approved, wallet not active, source of funds required, depositor identity required), or no EUR reference rate for the deposit's currency (`fx_rate_unavailable`); nothing was recorded."
          },
          "400": {
            "description": "`invalid_currency` (not a currency the platform knows) or `amount_too_large` (above EUR 1,000,000 in one deposit); also the generic bad request"
          },
          "503": {
            "description": "The bank's cash threshold cannot be read (`cash_threshold_unavailable`); nothing was recorded."
          }
        }
      },
      "get": {
        "operationId": "listCashDeposits",
        "tags": ["Cash Deposits"],
        "summary": "List cash deposits with optional filtering",
        "description": "Every filter runs over all deposits of the bank; `total` counts all\nmatches, not the page.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "pending",
                "auto_approved",
                "flagged",
                "approved",
                "rejected"
              ]
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Free text (case-insensitive, percent-encoded) over customer name and e-mail, depositor, branch, receipt number and id.",
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          },
          {
            "name": "credit_missing",
            "in": "query",
            "description": "`true`: approved (automatically or by an officer) and never credited to the account (POST /cash-deposits/{depositId}/reprocess).",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "from",
            "in": "query",
            "description": "Recorded on or after this day (UTC).",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "Recorded on or before this day (UTC).",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "description": "Sort column (amount by the EUR equivalent); ties by time. An unknown column is 400.",
            "schema": {
              "type": "string",
              "enum": ["created", "amount", "customer", "status"],
              "default": "created"
            }
          },
          {
            "name": "order",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": ["asc", "desc"],
              "default": "desc"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 100
            }
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Above 1,000,000 is 400.",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 1000000,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deposit list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CashDepositList"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/cash-deposits/{depositId}": {
      "get": {
        "operationId": "getCashDeposit",
        "tags": ["Cash Deposits"],
        "summary": "Get cash deposit details",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "depositId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deposit details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CashDeposit"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/cash-deposits/{depositId}/approve": {
      "post": {
        "operationId": "approveCashDeposit",
        "tags": ["Cash Deposits"],
        "summary": "Approve a flagged cash deposit (4-eyes principle)",
        "description": "Second-officer approval for deposits that exceeded the regulatory daily\naggregate threshold or triggered compliance flags. The approving officer\nmust differ from the processing officer (4-eyes principle). On approval,\na ledger transfer is created to credit the customer wallet. The\napproval stands when that credit fails: `credit` is then `failed`\nand POST /cash-deposits/{depositId}/reprocess posts it later.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "depositId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "approved_by": {
                    "type": "string",
                    "description": "Service calls only: admin user ID of the approving officer. For an admin session the officer is the session's (DEC-0043) and this field is ignored"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deposit approved and ledger transfer created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "compliance_status": {
                      "type": "string",
                      "example": "approved"
                    },
                    "customer_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "wallet_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "tenant_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "amount": {
                      "type": "integer"
                    },
                    "currency": {
                      "type": "string"
                    },
                    "credit": {
                      "type": "string",
                      "enum": ["posted", "failed"],
                      "description": "Whether the ledger credit was posted with the approval."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "403": {
            "description": "4-eyes violation (approver same as processing teller)"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/cash-deposits/{depositId}/reject": {
      "post": {
        "operationId": "rejectCashDeposit",
        "tags": ["Cash Deposits"],
        "summary": "Reject a flagged cash deposit",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "depositId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["reason"],
                "properties": {
                  "rejected_by": {
                    "type": "string",
                    "description": "Service calls only: admin user ID of the rejecting officer. For an admin session the officer is the session's (DEC-0043) and this field is ignored"
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 1
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deposit rejected",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "compliance_status": {
                      "type": "string",
                      "example": "rejected"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/cash-deposits/{depositId}/reprocess": {
      "post": {
        "operationId": "reprocessCashDeposit",
        "tags": ["Cash Deposits"],
        "summary": "Reprocess a cash deposit (retry compliance checks)",
        "description": "Re-runs the AML compliance pipeline for a previously failed or\nerrored cash deposit. Useful when a transient backend error\nprevented the initial compliance evaluation from completing.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "depositId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deposit reprocessed"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/cash-deposits/daily-aggregate/{customerId}": {
      "get": {
        "operationId": "getCashDepositDailyAggregate",
        "tags": ["Cash Deposits"],
        "summary": "Get daily cash deposit aggregate for a customer",
        "description": "Returns the total cash deposited today for the given customer,\nthe AML threshold, remaining capacity, and whether the threshold\nhas been exceeded. With `amount` (minor units of `currency`) it also\nsays what recording that deposit now would do, judged like POST\n/cash-deposits on the same day's total and profile (a preview:\nnothing is locked).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "amount",
            "in": "query",
            "description": "Minor units of `currency` (0 or absent: no preview).",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          {
            "name": "currency",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 3,
              "maxLength": 3,
              "default": "EUR"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Daily aggregate information",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CashDepositDailyAggregate"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_currency`, `amount_too_large`, or an invalid amount"
          },
          "422": {
            "description": "`fx_rate_unavailable`"
          },
          "503": {
            "description": "`cash_threshold_unavailable`"
          }
        }
      }
    },
    "/api/v1/cash-deposits/summary": {
      "get": {
        "operationId": "getCashDepositSummary",
        "tags": ["Cash Deposits"],
        "summary": "The cash desk of the bank at a glance",
        "description": "Deposits waiting for a second officer and approved deposits never\ncredited, each with the oldest one's time; today's deposits; and the\nthresholds of the bank's jurisdiction profile in EUR cents (null\nwhen the profile cannot be read: recording then fails closed with\n503 `cash_threshold_unavailable`). The bank is the cell session's,\nX-Tenant-ID in the platform scope.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Counts and thresholds",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "counts": {
                      "type": "object",
                      "properties": {
                        "waiting": {
                          "type": "integer"
                        },
                        "oldest_waiting_at": {
                          "type": ["string", "null"],
                          "format": "date-time"
                        },
                        "credit_missing": {
                          "type": "integer"
                        },
                        "oldest_credit_missing_at": {
                          "type": ["string", "null"],
                          "format": "date-time"
                        },
                        "today": {
                          "type": "integer"
                        }
                      }
                    },
                    "threshold": {
                      "type": ["object", "null"],
                      "properties": {
                        "currency": {
                          "type": "string",
                          "enum": ["EUR"]
                        },
                        "daily": {
                          "type": "integer",
                          "description": "A customer's cash of one day at or above it (EUR cents) waits for a second officer and needs the source of funds."
                        },
                        "single_review": {
                          "type": "integer",
                          "description": "One deposit at or above it (EUR cents) is flagged for a suspicion check."
                        },
                        "jurisdiction_code": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "No bank (`tenant_id is required`)"
          }
        }
      }
    },
    "/api/v1/cash-deposits/branches": {
      "get": {
        "operationId": "listCashDepositBranches",
        "tags": ["Cash Deposits"],
        "summary": "Branch names the bank's tellers recorded",
        "description": "The branch names in use (trimmed, one entry each), most recently\nused first, at most 100. finance-api keeps no branch register; the\ndesk offers these so one branch is written one way.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Branch names",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "branches": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string"
                          },
                          "deposits": {
                            "type": "integer"
                          },
                          "last_used_at": {
                            "type": "string",
                            "format": "date-time"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "No bank (`tenant_id is required`)"
          }
        }
      }
    },
    "/api/v1/holding-config": {
      "get": {
        "operationId": "listHoldingConfigs",
        "tags": ["HoldingPeriods"],
        "summary": "List holding period configurations for a tenant",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Tenant ID to filter configs"
          }
        ],
        "responses": {
          "200": {
            "description": "Holding period configurations",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "configs": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/HoldingPeriodConfig"
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "ledger_hold": {
                      "type": "boolean",
                      "nullable": true,
                      "description": "Whether the bank holds the money in the ledger (feature flag `feature.payments.holding_ledger_hold`); null when it could not be read."
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createHoldingConfig",
        "tags": ["HoldingPeriods"],
        "summary": "Create a holding period for incoming direct debits",
        "description": "One live configuration per bank, customer and payment method: a\nduplicate is 409 `holding_period_exists` (it was overwritten\nsilently before). Default: 5 calendar days for SEPA SDD. What it\ndoes today: the credit is posted at once; the hold is recorded\nfor reporting and returns (a ledger hold is planned). Staff `bank_admin` (super_admin reads only, DEC-0042); audited (`holding_period.created`).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["tenant_id"],
                "properties": {
                  "tenant_id": {
                    "type": "string"
                  },
                  "customer_id": {
                    "type": "string",
                    "description": "NULL = tenant default"
                  },
                  "customer_group": {
                    "type": "string"
                  },
                  "payment_method": {
                    "type": "string",
                    "enum": [
                      "SEPA_SDD",
                      "SEPA_SDD_B2B",
                      "SEPA_SCT",
                      "CARD",
                      "OTHER"
                    ],
                    "default": "SEPA_SDD"
                  },
                  "holding_days": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 30,
                    "default": 5
                  },
                  "calendar_type": {
                    "type": "string",
                    "enum": ["CALENDAR", "BUSINESS"],
                    "default": "CALENDAR"
                  },
                  "risk_score": {
                    "type": "string",
                    "enum": ["LOW", "MEDIUM", "HIGH"]
                  },
                  "auto_adjust": {
                    "type": "boolean",
                    "default": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Holding config created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HoldingPeriodConfig"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_input`, `holding_days_invalid`, `auto_adjust_invalid`"
          },
          "409": {
            "description": "`holding_period_exists`"
          }
        }
      }
    },
    "/api/v1/holding-config/{configId}": {
      "patch": {
        "operationId": "updateHoldingConfig",
        "tags": ["HoldingPeriods"],
        "summary": "Update a holding period configuration",
        "description": "Booleans are JSON booleans. `risk_score` and `customer_group`:\nabsent keeps, null or \"\" clears. Audited (`holding_period.updated`).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "configId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "holding_days": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 30
                  },
                  "calendar_type": {
                    "type": "string",
                    "enum": ["CALENDAR", "BUSINESS"]
                  },
                  "risk_score": {
                    "type": "string",
                    "enum": ["LOW", "MEDIUM", "HIGH"],
                    "nullable": true
                  },
                  "customer_group": {
                    "type": "string",
                    "nullable": true
                  },
                  "auto_adjust": {
                    "type": "boolean"
                  },
                  "is_active": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Config updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HoldingPeriodConfig"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_input`, `risk_score_invalid`, `auto_adjust_invalid`, `is_active_invalid`"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "delete": {
        "operationId": "deleteHoldingConfig",
        "tags": ["HoldingPeriods"],
        "summary": "Switch a holding period off (kept)",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "configId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Config switched off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HoldingPeriodConfig"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/holding-config/pending": {
      "get": {
        "operationId": "listPendingSettlements",
        "tags": ["HoldingPeriods"],
        "summary": "List transfers in SETTLED_PENDING state",
        "description": "Returns the direct debit credits still in their holding period, in\nthe caller's scope (the bank's own; every bank's in the platform\nscope), at most 100, the earliest end first. `ledger_hold`: the\namount is held in the ledger (not available to the customer).\n`overdue`: the period ended and the settlement scheduler has not\nreleased it yet (switched off, or failing); `overdue` at the top\nlevel counts them. `customer_id`: the customer whose account is\ncredited.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Pending settlements",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "settlements": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "transfer_id": {
                            "type": "string"
                          },
                          "debit_account_id": {
                            "type": "string"
                          },
                          "credit_account_id": {
                            "type": "string"
                          },
                          "amount": {
                            "type": "integer",
                            "format": "int64"
                          },
                          "currency": {
                            "type": "string"
                          },
                          "settlement_status": {
                            "type": "string"
                          },
                          "settlement_held_until": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "created_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "ledger_hold": {
                            "type": "boolean"
                          },
                          "overdue": {
                            "type": "boolean"
                          },
                          "customer_id": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "overdue": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/holding-config/scheduler": {
      "get": {
        "operationId": "getSettlementSchedulerStatus",
        "tags": ["HoldingPeriods"],
        "summary": "Get settlement release scheduler status",
        "description": "Run statistics of the settlement release scheduler (BR-EF-011) and\nits stored switch (a platform setting, DEC-0042; migration 266).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Scheduler status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "enabled": {
                      "type": "boolean"
                    },
                    "interval_seconds": {
                      "type": "integer"
                    },
                    "last_run_timestamp": {
                      "type": "integer",
                      "format": "int64"
                    },
                    "last_released_count": {
                      "type": "integer"
                    },
                    "total_released": {
                      "type": "integer"
                    },
                    "runs_completed": {
                      "type": "integer"
                    },
                    "runs_failed": {
                      "type": "integer"
                    },
                    "ledger_holds_released": {
                      "type": "integer",
                      "description": "Ledger holds posted since start (migration 287)"
                    },
                    "ledger_holds_expired": {
                      "type": "integer",
                      "description": "Ledger holds found expired since start (alert rows)"
                    },
                    "ledger_holds_failed": {
                      "type": "integer",
                      "description": "Ledger hold releases that failed and are retried next run"
                    },
                    "stored_enabled": {
                      "type": "boolean",
                      "nullable": true
                    },
                    "stored_interval_seconds": {
                      "type": "integer"
                    },
                    "owner": {
                      "type": "string",
                      "example": "platform"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "configureSettlementScheduler",
        "tags": ["HoldingPeriods"],
        "summary": "Configure the settlement release scheduler (platform)",
        "description": "A super_admin in the platform scope only (403 `platform_only`\notherwise). `enabled` is a JSON boolean (it was read as a string,\nso a switch-off was dropped). Stored in the database and audited\n(`settlement_scheduler.configured`) before the running scheduler\nfollows; the stored switch survives a restart.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "enabled": {
                    "type": "boolean"
                  },
                  "interval_seconds": {
                    "type": "integer",
                    "minimum": 60,
                    "maximum": 3600
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated scheduler configuration"
          },
          "400": {
            "description": "`enabled_invalid`, `interval_seconds_invalid` (`interval_seconds` 60..3600)."
          },
          "403": {
            "description": "`platform_only`; `forbidden_role` from the staff route gate (DEC-0043)"
          }
        }
      }
    },
    "/api/v1/transaction-mappings": {
      "get": {
        "operationId": "listTransactionMappings",
        "tags": ["TransactionMappings"],
        "summary": "List transaction code mappings for a tenant",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Transaction code mappings",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "mappings": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/TransactionCodeMapping"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createTransactionMapping",
        "tags": ["TransactionMappings"],
        "summary": "Create a posting rule (transaction code mapping)",
        "description": "Maps a transaction code to a ledger account of the bank\n(`finance_account_owner`, DEC-0026; free text is refused with\n`unknown_account`) and a posting type, for the bank, one customer,\nand optionally one payment method. A booking resolves its rule\nwith its payment method (SEPA_SDD, SEPA_SDD_B2B, SEPA_SCT, CARD,\nOTHER), the most specific first. One live rule per tenant,\ncustomer, code and payment method: a duplicate is 409. Staff `bank_admin` (super_admin reads only, DEC-0042); audited (`posting_rule.created`).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "tenant_id",
                  "transaction_code",
                  "description",
                  "target_account_id",
                  "posting_type"
                ],
                "properties": {
                  "tenant_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "customer_id": {
                    "type": "string",
                    "description": "NULL = tenant default"
                  },
                  "transaction_code": {
                    "type": "string",
                    "maxLength": 50,
                    "pattern": "^[A-Z0-9_.-]{1,50}$"
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 255
                  },
                  "target_account_id": {
                    "type": "string",
                    "description": "Ledger account hex ID of the bank"
                  },
                  "posting_type": {
                    "type": "string",
                    "enum": ["CREDIT", "DEBIT"]
                  },
                  "payment_method": {
                    "type": "string",
                    "enum": [
                      "SEPA_SDD",
                      "SEPA_SDD_B2B",
                      "SEPA_SCT",
                      "CARD",
                      "OTHER"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Mapping created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransactionCodeMapping"
                }
              }
            }
          },
          "400": {
            "description": "`unknown_account`, `invalid_input`"
          },
          "409": {
            "description": "`posting_rule_exists`"
          }
        }
      }
    },
    "/api/v1/transaction-mappings/{mappingId}": {
      "get": {
        "operationId": "getTransactionMapping",
        "tags": ["TransactionMappings"],
        "summary": "Get a single transaction code mapping",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "mappingId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Mapping details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransactionCodeMapping"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "patch": {
        "operationId": "updateTransactionMapping",
        "tags": ["TransactionMappings"],
        "summary": "Update a transaction code mapping",
        "description": "`is_active` is a JSON boolean (it was dropped before);\nre-activating a rule whose key has another live rule is 409.\nAudited (`posting_rule.updated`).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "mappingId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "description": {
                    "type": "string"
                  },
                  "target_account_id": {
                    "type": "string"
                  },
                  "posting_type": {
                    "type": "string",
                    "enum": ["CREDIT", "DEBIT"]
                  },
                  "is_active": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Mapping updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransactionCodeMapping"
                }
              }
            }
          },
          "400": {
            "description": "`unknown_account`, `is_active_invalid`"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`posting_rule_exists`"
          }
        }
      },
      "delete": {
        "operationId": "deleteTransactionMapping",
        "tags": ["TransactionMappings"],
        "summary": "Switch a transaction code mapping off (kept)",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "mappingId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Mapping deactivated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransactionCodeMapping"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/transaction-mappings/customer/{customerId}": {
      "get": {
        "operationId": "listCustomerTransactionMappings",
        "tags": ["TransactionMappings"],
        "summary": "List customer-specific mapping overrides",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Customer mapping overrides",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "mappings": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/TransactionCodeMapping"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/postings/manual-review": {
      "get": {
        "operationId": "listManualReviewItems",
        "tags": ["Postings"],
        "summary": "Unassigned bookings (manual review)",
        "description": "Bookings without a posting rule, recorded MANUAL_REVIEW on the\nsuspense account, with the bank's decision when there is one.\n`state`: open (default), decided or all. `moves_money` is always\nfalse: a decision records where a booking belongs.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["open", "decided", "all"],
              "default": "open"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Unassigned bookings",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PostingAuditEntry"
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "moves_money": {
                      "type": "boolean",
                      "example": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/postings/manual-review/{auditId}/resolve": {
      "post": {
        "operationId": "resolveManualReview",
        "tags": ["Postings"],
        "summary": "Record where an unassigned booking belongs",
        "description": "Append-only decision (migration 267: one per booking, the staff\nactor of the session, a reason, a ledger account of the bank). The\nposting audit row is never rewritten and no money moves. A second\ndecision is 409 `already_decided`. Staff `bank_admin` (super_admin reads only, DEC-0042); audited (`unassigned_booking.resolved`).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "auditId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["target_account_id", "reason"],
                "properties": {
                  "target_account_id": {
                    "type": "string",
                    "description": "Ledger account hex ID of the bank"
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 1000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Decision recorded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PostingReviewDecision"
                }
              }
            }
          },
          "400": {
            "description": "`reason_required`, `target_account_required`, `unknown_account`"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`already_decided`"
          }
        }
      }
    },
    "/api/v1/postings/manual-review/{auditId}/reject": {
      "post": {
        "operationId": "rejectManualReview",
        "tags": ["Postings"],
        "summary": "Reject an unassigned booking",
        "description": "Append-only decision with a reason and the staff actor; no money\nmoves. 409 `already_decided` on a second decision. Audited\n(`unassigned_booking.rejected`).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "auditId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReasonRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Decision recorded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PostingReviewDecision"
                }
              }
            }
          },
          "400": {
            "description": "`reason_required`"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`already_decided`"
          }
        }
      }
    },
    "/api/v1/reconciliation/status": {
      "get": {
        "operationId": "getReconciliationStatus",
        "tags": ["Reconciliation"],
        "summary": "Retrieve current reconciliation engine status",
        "description": "Returns the reconciliation engine's current state including whether a\nrun is in progress, the last completed run timestamp, and summary\nmetrics (matched, unmatched, drift counts). Used for operational\ndashboards and alerting.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Reconciliation status (PG + in-memory running job)"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          }
        }
      }
    },
    "/api/v1/reconciliation/history": {
      "get": {
        "operationId": "getReconciliationHistory",
        "tags": ["Reconciliation"],
        "summary": "Retrieve reconciliation run history with match metrics",
        "description": "Returns historical reconciliation runs with per-run statistics:\ntotal entries processed, matched count, unmatched count, drift\namount, and confidence score distribution. Supports safeguarding\naudits and regulatory reporting.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Past reconciliation runs with drift/match counts"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          }
        }
      }
    },
    "/api/v1/reconciliation/run": {
      "post": {
        "operationId": "runReconciliation",
        "tags": ["Reconciliation"],
        "summary": "Trigger manual reconciliation run",
        "description": "Initiates an asynchronous reconciliation run comparing ledger state\n(ledger + transfer metadata) against imported bank\nstatement entries. Returns `202 Accepted` immediately; progress can\nbe monitored via `GET /api/v1/reconciliation/status`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Reconciliation started"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          }
        }
      }
    },
    "/api/v1/reconciliation/statements": {
      "get": {
        "operationId": "listBankStatements",
        "tags": ["Reconciliation"],
        "summary": "List imported ISO 20022 bank statements",
        "description": "Returns all imported CAMT.053 bank statements with entry counts,\nmatch statistics, and balance summaries. Each statement represents\na single bank account's activity for a reporting period.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Imported CAMT.053 bank statements",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "statements": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/BankStatement"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          }
        }
      }
    },
    "/api/v1/reconciliation/import": {
      "post": {
        "operationId": "importBankStatement",
        "tags": ["Reconciliation"],
        "summary": "Import CAMT.053 bank statement (ISO 20022 XML)",
        "description": "Parses an ISO 20022 CAMT.053 XML bank statement and performs\nconfidence-based matching against ledger transfer metadata. Matching\nstrategies include:\n\n- **Exact match** \u2014 amount, currency, reference, and date all match\n- **Amount-only** \u2014 amount and currency match, reference differs\n- **Reference-only** \u2014 reference matches, amount differs\n- **Partial** \u2014 some fields match with lower confidence\n- **Duplicate detection** \u2014 identifies potential duplicate entries\n\nEach entry receives a confidence score (0.0-1.0). Unmatched entries\nare flagged for manual review. Statement and entry data are persisted\nto the database for audit trail and regulatory reporting.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/xml": {
              "schema": {
                "type": "string"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Import results with match confidence scores"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          }
        }
      }
    },
    "/api/v1/deposit-cap/unlatch-requests": {
      "get": {
        "operationId": "listDepositCapUnlatches",
        "tags": ["Safeguarding"],
        "summary": "Art. 1b intake latch clears (auto and four-eyes manual)",
        "description": "The intake latch is set by a post-check overshoot and clears itself\nwhen a later check finds utilisation under the cap (kind auto). An\nunreadable ledger never latches; it answers 503 per request.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SafeguardingTenant"
          }
        ],
        "responses": {
          "200": {
            "description": "Newest first",
            "at most 200": null
          }
        }
      },
      "post": {
        "operationId": "requestDepositCapUnlatch",
        "tags": ["Safeguarding"],
        "summary": "Request a staff unlatch (a second person approves)",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SafeguardingTenant"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": ["reason"],
                "properties": {
                  "reason": {
                    "type": "string",
                    "maxLength": 500
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Pending request",
            "bound to the current latch episode": null
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "409": {
            "description": "not_latched, request_pending, or still_over_cap (a manual unlatch while at or over the cap is not allowed; change the cap instead)"
          },
          "503": {
            "description": "deposit_cap_unavailable or fx_rate_unavailable (utilisation unreadable)"
          }
        }
      }
    },
    "/api/v1/deposit-cap/unlatch-requests/{id}/approve": {
      "post": {
        "operationId": "approveDepositCapUnlatch",
        "tags": ["Safeguarding"],
        "summary": "Approve and clear the latch (not the requester)",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SafeguardingTenant"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Approved; intake_blocked is false"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "404": {
            "description": "Not a request of this tenant"
          },
          "409": {
            "description": "four_eyes_required, wrong_state, not_latched, episode_closed, latch_changed (a newer overshoot; retry) or still_over_cap"
          },
          "503": {
            "description": "deposit_cap_unavailable or fx_rate_unavailable"
          }
        }
      }
    },
    "/api/v1/deposit-cap/unlatch-requests/{id}/reject": {
      "post": {
        "operationId": "rejectDepositCapUnlatch",
        "tags": ["Safeguarding"],
        "summary": "Reject the unlatch request (not the requester)",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SafeguardingTenant"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Rejected; the latch stays"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "404": {
            "description": "Not a request of this tenant"
          },
          "409": {
            "description": "four_eyes_required, wrong_state, not_latched or episode_closed"
          }
        }
      }
    },
    "/api/v1/deposit-cap/unlatch-requests/{id}/cancel": {
      "post": {
        "operationId": "cancelDepositCapUnlatch",
        "tags": ["Safeguarding"],
        "summary": "The requester withdraws a pending unlatch request",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SafeguardingTenant"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Cancelled"
          },
          "403": {
            "description": "not_requester"
          },
          "404": {
            "description": "Not a request of this tenant"
          },
          "409": {
            "description": "wrong_state"
          }
        }
      }
    },
    "/api/v1/safeguarding/accounts": {
      "get": {
        "operationId": "listSafeguardingAccounts",
        "tags": ["Safeguarding"],
        "summary": "List the tenant's safeguarding accounts",
        "description": "Read roles bank_admin, cfo, coo, auditor, mlro, super_admin, or a service key.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SafeguardingTenant"
          }
        ],
        "responses": {
          "200": {
            "description": "Accounts, oldest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SafeguardingAccount"
                  }
                }
              }
            }
          },
          "403": {
            "description": "forbidden, or tenant_required when X-Tenant-ID is missing"
          }
        }
      },
      "post": {
        "operationId": "requestSafeguardingAccount",
        "tags": ["Safeguarding"],
        "summary": "Request a new safeguarding account (four-eyes)",
        "description": "Creates the account as pending_approval. A second staff user approves\nit. Identity fields (currency, method, IBAN) never change afterwards.\nRoles bank_admin and cfo (the platform reads, it does not change a\nbank's safeguarding); a service key is refused.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SafeguardingTenant"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "currency",
                  "method",
                  "institution_name",
                  "account_name"
                ],
                "properties": {
                  "currency": {
                    "type": "string",
                    "example": "EUR"
                  },
                  "method": {
                    "type": "string",
                    "enum": [
                      "segregated_account",
                      "secure_assets",
                      "insurance",
                      "guarantee"
                    ]
                  },
                  "institution_name": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "institution_bic": {
                    "type": "string",
                    "nullable": true,
                    "example": "CAIXESBBXXX"
                  },
                  "iban": {
                    "type": "string",
                    "nullable": true,
                    "description": "Required for segregated_account; mod-97 checked"
                  },
                  "account_name": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "designation_ref": {
                    "type": "string",
                    "nullable": true,
                    "maxLength": 200
                  },
                  "designation_acknowledged_on": {
                    "type": "string",
                    "format": "date",
                    "nullable": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Account awaiting approval",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SafeguardingAccount"
                }
              }
            }
          },
          "400": {
            "description": "invalid_body or invalid_field with the field name"
          },
          "403": {
            "description": "forbidden"
          },
          "409": {
            "description": "duplicate_account (a live registration with the same IBAN and currency)"
          }
        }
      }
    },
    "/api/v1/safeguarding/accounts/{id}/approve": {
      "post": {
        "operationId": "approveSafeguardingAccount",
        "tags": ["Safeguarding"],
        "summary": "Approve the pending creation or closure (second person)",
        "description": "The requester of the pending change cannot approve it (409 four_eyes_required).",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SafeguardingTenant"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Account after the change (active or closed)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SafeguardingAccount"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "404": {
            "description": "Not an account of this tenant"
          },
          "409": {
            "description": "four_eyes_required or wrong_state"
          }
        }
      }
    },
    "/api/v1/safeguarding/accounts/{id}/reject": {
      "post": {
        "operationId": "rejectSafeguardingAccount",
        "tags": ["Safeguarding"],
        "summary": "Reject (or withdraw) the pending creation or closure",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SafeguardingTenant"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Account after the change (rejected, or active again)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SafeguardingAccount"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "404": {
            "description": "Not an account of this tenant"
          },
          "409": {
            "description": "wrong_state"
          }
        }
      }
    },
    "/api/v1/safeguarding/accounts/{id}/close": {
      "post": {
        "operationId": "requestSafeguardingAccountClosure",
        "tags": ["Safeguarding"],
        "summary": "Request the closure of an active account (four-eyes)",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SafeguardingTenant"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Account in closing_requested",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SafeguardingAccount"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "404": {
            "description": "Not an account of this tenant"
          },
          "409": {
            "description": "wrong_state"
          }
        }
      }
    },
    "/api/v1/safeguarding/statements": {
      "post": {
        "operationId": "importSafeguardingStatement",
        "tags": ["Safeguarding"],
        "summary": "Import daily closing balances (CSV or camt.053)",
        "description": "CSV header business_date,iban,currency,closing_balance[,statement_ref].\ncamt.053: the CLBD balance of every Stmt. All or nothing: any\nmalformed line, repeated account/day, or IBAN/currency that is not a\nlive account of the tenant rejects the file. Re-importing the same\nfile stores nothing new (SHA-256). A later file for the same account\nand day supersedes the earlier one; both stay on record. The body is\nat most 1 MB (the server's body limit; larger is 413): split a longer\nstatement by day or account.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SafeguardingTenant"
          },
          {
            "name": "format",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": ["csv", "camt053"]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "text/csv": {
              "schema": {
                "type": "string"
              }
            },
            "application/xml": {
              "schema": {
                "type": "string"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Stored",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "lines": {
                      "type": "integer"
                    },
                    "stored": {
                      "type": "integer"
                    },
                    "file_sha256": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "format_required"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "422": {
            "description": "invalid_statement (reason, line) or unknown_account (accounts)"
          }
        }
      }
    },
    "/api/v1/safeguarding/balances": {
      "get": {
        "operationId": "listSafeguardingBalances",
        "tags": ["Safeguarding"],
        "summary": "Imported closing balances",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SafeguardingTenant"
          },
          {
            "name": "date",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Balances",
            "newest day first (at most 1000)": null
          },
          "400": {
            "description": "invalid_date"
          }
        }
      }
    },
    "/api/v1/safeguarding/reconciliation": {
      "get": {
        "operationId": "getSafeguardingReconciliation",
        "tags": ["Safeguarding"],
        "summary": "Relevant funds against the safeguarded balance, per currency",
        "description": "Relevant funds are computed live from TigerBeetle (posted balances of\nthe tenant's customer e-money accounts, negatives apart) plus cash\nreceived and not yet posted. They are compared with the closing\nbalances of `date` (default: latest imported day). status is balanced,\nshortfall, excess, incomplete (an active account has no statement for\nthe day) or unknown. outbound_in_transit is not tracked yet. The\nledger is read fail-closed: 503, never a figure, when it cannot be read.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SafeguardingTenant"
          },
          {
            "name": "date",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Reconciliation per currency"
          },
          "400": {
            "description": "invalid_date"
          },
          "503": {
            "description": "ledger_unavailable or ledger_inconsistent"
          }
        }
      }
    },
    "/api/v1/reconciliation/schedule": {
      "get": {
        "operationId": "getReconSchedule",
        "tags": ["Reconciliation"],
        "summary": "Retrieve automated T+1 reconciliation schedule",
        "description": "Returns the current automated reconciliation schedule configuration.\nT+1 scheduling runs reconciliation at a fixed UTC hour daily,\ncomparing the previous business day's transactions against bank\nstatement data.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Schedule configuration"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          }
        }
      },
      "post": {
        "operationId": "updateReconSchedule",
        "tags": ["Reconciliation"],
        "summary": "Configure automated T+1 reconciliation schedule",
        "description": "Enables or updates the automated daily reconciliation schedule.\nThe `hour_utc` parameter sets the execution time (default 02:00 UTC).\nBuilt for daily safeguarding reconciliation.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "enabled": {
                    "type": "boolean"
                  },
                  "hour_utc": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 23,
                    "default": 2
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Schedule updated"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          }
        }
      }
    },
    "/api/v1/reconciliation/statements/{statementId}/entries": {
      "get": {
        "operationId": "listStatementEntries",
        "tags": ["Reconciliation"],
        "summary": "List entries for an imported bank statement",
        "description": "Returns all parsed entries from a CAMT.053 bank statement with their\nmatch status, confidence score, matched transfer ID, and review metadata.\nEntries can be in states: `unmatched`, `exact`, `amount_only`, `ref_only`,\n`partial`, `manual_match`, `investigated`, `rejected`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/StatementId"
          }
        ],
        "responses": {
          "200": {
            "description": "Statement entries with match results",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "entries": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/StatementEntry"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          }
        }
      }
    },
    "/api/v1/reconciliation/entries/{entryId}/match": {
      "patch": {
        "operationId": "manualMatchEntry",
        "tags": ["Reconciliation"],
        "summary": "Manual match entry to a specific ledger transfer",
        "description": "Links an unmatched bank statement entry to a specific ledger transfer.\nSets match_status to `manual_match` with confidence 1.0 and recalculates\nthe parent statement's matched/unmatched counts. Requires SUPER_ADMIN or\nMLRO role.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/EntryId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["transfer_id"],
                "properties": {
                  "transfer_id": {
                    "type": "string",
                    "description": "Ledger transfer ID to match against"
                  },
                  "note": {
                    "type": "string"
                  },
                  "reviewer": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Entry matched",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "match_status": {
                      "type": "string",
                      "example": "manual_match"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          }
        }
      }
    },
    "/api/v1/reconciliation/entries/{entryId}/investigate": {
      "patch": {
        "operationId": "investigateEntry",
        "tags": ["Reconciliation"],
        "summary": "Mark entry as investigated (reviewed but unresolved)",
        "description": "Flags the entry as investigated by a reviewer. The entry remains\nunmatched but is excluded from rematch operations. Records the\nreviewer identity and optional investigation note.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/EntryId"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "note": {
                    "type": "string"
                  },
                  "reviewer": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Entry marked as investigated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "match_status": {
                      "type": "string",
                      "example": "investigated"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          }
        }
      }
    },
    "/api/v1/reconciliation/entries/{entryId}/reject": {
      "patch": {
        "operationId": "rejectEntry",
        "tags": ["Reconciliation"],
        "summary": "Reject entry as not relevant (bank fee, duplicate, etc.)",
        "description": "Marks the entry as rejected. Rejected entries are excluded from\nmatch counts and rematch operations. Common use cases: bank fees,\nduplicate entries, non-transactional items.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/EntryId"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "note": {
                    "type": "string"
                  },
                  "reviewer": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Entry rejected",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "match_status": {
                      "type": "string",
                      "example": "rejected"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          }
        }
      }
    },
    "/api/v1/reconciliation/entries/{entryId}/note": {
      "patch": {
        "operationId": "addEntryNote",
        "tags": ["Reconciliation"],
        "summary": "Add review note to entry without changing match status",
        "description": "Attaches or updates a review note on an entry. Does not change the\nmatch status. Used for documenting findings during the review process.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/EntryId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["note"],
                "properties": {
                  "note": {
                    "type": "string",
                    "minLength": 1
                  },
                  "reviewer": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Note added",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          }
        }
      }
    },
    "/api/v1/reconciliation/statements/{statementId}/approve": {
      "post": {
        "operationId": "approveStatement",
        "tags": ["Reconciliation"],
        "summary": "Approve bank statement (operations sign-off)",
        "description": "Marks a bank statement as approved by operations personnel. This is the\nfinal step in the reconciliation review workflow. Approved statements\ncannot be re-opened. The reviewer identity and timestamp are recorded.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/StatementId"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reviewer": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Statement approved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "status": {
                      "type": "string",
                      "example": "approved"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          }
        }
      }
    },
    "/api/v1/reconciliation/statements/{statementId}/rematch": {
      "post": {
        "operationId": "rematchStatement",
        "tags": ["Reconciliation"],
        "summary": "Re-run matching with relaxed tolerance for unresolved entries",
        "description": "Re-runs the matching algorithm for all unresolved entries in a statement\nagainst current ledger data. Uses 1 EUR/USD tolerance (100 minor units)\ncompared to exact match during initial import. Entries already manually\nmatched, investigated, or rejected are skipped.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/StatementId"
          }
        ],
        "responses": {
          "200": {
            "description": "Rematch results",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "matched": {
                      "type": "integer"
                    },
                    "unmatched": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          }
        }
      }
    },
    "/api/v1/jurisdictions": {
      "get": {
        "operationId": "listJurisdictions",
        "tags": ["Jurisdictions"],
        "summary": "List all jurisdiction profiles",
        "description": "`{\"jurisdictions\":[...]}`: every profile with its retention, AML\nretention and basis, authorities and `cdd_config` (SAR deadline\n`sar_sla_hours`, MROS hold `sar_hold_business_days`,\n`case_review_days`, periodic review). Readable by staff and services.\n\nJurisdiction profiles, holidays and the chart of accounts template\nare shared by every bank of a jurisdiction (DEC-0042): every write\nbelow is a staff `super_admin`'s in the platform scope (403\n`forbidden_role` for other roles and the service key, 403\n`platform_scope_required` with an `X-Tenant-ID`), writes one\n`platform.setting.changed` audit row with the values before and\nafter, and the database refuses writes outside the platform scope\n(migration 270).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Jurisdiction profile list"
          }
        }
      },
      "post": {
        "operationId": "createJurisdiction",
        "tags": ["Jurisdictions"],
        "summary": "Create a jurisdiction profile (platform)",
        "description": "Defines a regulatory jurisdiction with its accounting standard, business\nday calendar, retention requirements, and supervisory authorities.\n409 `jurisdiction_exists` for a code already defined.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "jurisdiction_code",
                  "display_name",
                  "accounting_standard"
                ],
                "properties": {
                  "jurisdiction_code": {
                    "type": "string",
                    "description": "ISO 3166-1 alpha-2 (e.g., DE, AT, ES)"
                  },
                  "display_name": {
                    "type": "string"
                  },
                  "accounting_standard": {
                    "type": "string",
                    "enum": ["HGB", "PGC", "UGB", "PCG", "DGAAP", "IFRS", "OR"]
                  },
                  "business_day_calendar": {
                    "type": "string",
                    "description": "Calendar code for business day calculation"
                  },
                  "retention_years": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 30,
                    "default": 10
                  },
                  "default_currency": {
                    "type": "string",
                    "default": "EUR"
                  },
                  "timezone": {
                    "type": "string",
                    "default": "Europe/Berlin"
                  },
                  "locale": {
                    "type": "string",
                    "default": "de-DE"
                  },
                  "fiu_authority": {
                    "type": "string"
                  },
                  "tax_reporting_system": {
                    "type": "string"
                  },
                  "supervisory_authority": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Jurisdiction created"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          }
        }
      }
    },
    "/api/v1/jurisdictions/{code}": {
      "get": {
        "operationId": "getJurisdiction",
        "tags": ["Jurisdictions"],
        "summary": "Get a jurisdiction profile by code",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "ISO 3166-1 alpha-2 code"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Jurisdiction profile"
          },
          "404": {
            "description": "Jurisdiction not found"
          }
        }
      },
      "patch": {
        "operationId": "updateJurisdiction",
        "tags": ["Jurisdictions"],
        "summary": "Update a jurisdiction profile (platform)",
        "description": "Names the fields to change; the others keep their value.\n`aml_retention_years` and `aml_retention_basis` go together (null\nclears both). `cdd_config` names members to set (null removes one);\nother members stay. Out of range: 400 `invalid_field` with `field`\n(`cdd_config.<member>` for a member).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "display_name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "retention_years": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 30
                  },
                  "aml_retention_years": {
                    "type": ["integer", "null"],
                    "minimum": 1,
                    "maximum": 50
                  },
                  "aml_retention_basis": {
                    "type": ["string", "null"],
                    "maxLength": 200
                  },
                  "fiu_authority": {
                    "type": "string"
                  },
                  "tax_reporting_system": {
                    "type": "string"
                  },
                  "supervisory_authority": {
                    "type": "string"
                  },
                  "timezone": {
                    "type": "string"
                  },
                  "locale": {
                    "type": "string"
                  },
                  "is_active": {
                    "type": "boolean"
                  },
                  "cdd_config": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "sar_sla_hours": {
                        "type": ["integer", "null"],
                        "minimum": 1,
                        "maximum": 720
                      },
                      "sar_hold_business_days": {
                        "type": ["integer", "null"],
                        "minimum": 1,
                        "maximum": 30
                      },
                      "case_review_days": {
                        "type": ["integer", "null"],
                        "minimum": 1,
                        "maximum": 365
                      },
                      "periodic_review_enabled": {
                        "type": ["boolean", "null"]
                      },
                      "periodic_review_months_high": {
                        "type": ["integer", "null"],
                        "minimum": 1,
                        "maximum": 120
                      },
                      "periodic_review_months_other": {
                        "type": ["integer", "null"],
                        "minimum": 1,
                        "maximum": 120
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated jurisdiction (the profile after the change)"
          },
          "400": {
            "description": "`invalid_field` with `field`"
          },
          "403": {
            "description": "`forbidden_role`, `platform_scope_required`"
          },
          "404": {
            "description": "Jurisdiction not found"
          }
        }
      }
    },
    "/api/v1/jurisdictions/assign": {
      "post": {
        "operationId": "assignJurisdictionToTenant",
        "tags": ["Jurisdictions"],
        "summary": "Assign a jurisdiction to a tenant (platform)",
        "description": "A staff `super_admin` in the platform scope; one audit row on the\ntenant with the jurisdiction before and after.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["tenant_id", "jurisdiction_code"],
                "properties": {
                  "tenant_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "jurisdiction_code": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Jurisdiction assigned to tenant"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "404": {
            "description": "Tenant not found"
          }
        }
      }
    },
    "/api/v1/jurisdictions/holidays": {
      "get": {
        "operationId": "listHolidays",
        "tags": ["Jurisdictions"],
        "summary": "List holidays for a calendar",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "calendar_code",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "year",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Holiday list"
          }
        }
      },
      "post": {
        "operationId": "createHoliday",
        "tags": ["Jurisdictions"],
        "summary": "Add a holiday to a calendar (platform)",
        "description": "The calendar must be one a jurisdiction uses, `TARGET2`, or one that\nalready lists days (else 400 `invalid_field`). A date the calendar\nalready lists is 409 `holiday_exists` (never overwritten).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["calendar_code", "holiday_date", "holiday_name"],
                "properties": {
                  "calendar_code": {
                    "type": "string"
                  },
                  "holiday_date": {
                    "type": "string",
                    "format": "date"
                  },
                  "holiday_name": {
                    "type": "string"
                  },
                  "holiday_type": {
                    "type": "string",
                    "enum": ["PUBLIC", "BANK", "REGIONAL", "TARGET2"],
                    "default": "PUBLIC"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Holiday created"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "400": {
            "description": "`invalid_field` with `field`"
          },
          "409": {
            "description": "`holiday_exists`"
          }
        }
      }
    },
    "/api/v1/jurisdictions/holidays/{holidayId}": {
      "patch": {
        "operationId": "updateHoliday",
        "tags": ["Jurisdictions"],
        "summary": "Rename a holiday or change its type (platform)",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "holidayId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "holiday_name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 255
                  },
                  "holiday_type": {
                    "type": "string",
                    "enum": ["PUBLIC", "BANK", "REGIONAL", "TARGET2"]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The holiday after the change"
          },
          "404": {
            "description": "Holiday not found"
          }
        }
      },
      "delete": {
        "operationId": "deleteHoliday",
        "tags": ["Jurisdictions"],
        "summary": "Delete a holiday (platform)",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "holidayId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Holiday deleted"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "404": {
            "description": "Holiday not found"
          }
        }
      }
    },
    "/api/v1/jurisdictions/coa": {
      "get": {
        "operationId": "listChartOfAccountsTemplate",
        "tags": ["Jurisdictions"],
        "summary": "List chart of accounts template by accounting standard",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "standard",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": ["HGB", "PGC", "UGB", "PCG", "DGAAP", "IFRS"]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "CoA template entries"
          }
        }
      }
    },
    "/api/v1/jurisdictions/business-days/add": {
      "get": {
        "operationId": "addBusinessDays",
        "tags": ["Jurisdictions"],
        "summary": "Calculate a future business day",
        "description": "Adds N business days to a given date, skipping weekends and holidays\ndefined in the specified calendar. Used for settlement date calculation.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "calendar",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "date",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "days",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Calculated business day result"
          }
        }
      }
    },
    "/api/v1/integrations": {
      "get": {
        "operationId": "listIntegrationProviders",
        "tags": ["Integration"],
        "summary": "List integration providers (optional domain filter)",
        "description": "Returns all configured integration providers from the database registry.\nSupports optional `domain` query parameter to filter by integration domain\n(banking, kyc, kyb, aml, payment, card, fx).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "domain",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": ["banking", "kyc", "kyb", "aml", "payment", "card", "fx"]
            },
            "description": "Filter by integration domain"
          }
        ],
        "responses": {
          "200": {
            "description": "Provider list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "providers": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/IntegrationProvider"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createIntegrationProvider",
        "tags": ["Integration"],
        "summary": "Register new integration provider",
        "description": "A super_admin staff session in the platform scope only (DEC-0042; 403 `forbidden_role` otherwise).",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateIntegrationProviderRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Provider created"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "409": {
            "description": "Duplicate provider (domain + provider_name + tenant_id)"
          }
        }
      }
    },
    "/api/v1/integrations/{providerId}": {
      "get": {
        "operationId": "getIntegrationProvider",
        "tags": ["Integration"],
        "summary": "Get integration provider by ID",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "providerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Provider details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationProvider"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "patch": {
        "operationId": "updateIntegrationProvider",
        "tags": ["Integration"],
        "summary": "Update integration provider configuration",
        "description": "A super_admin staff session in the platform scope only (403 `forbidden_role` otherwise).",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "providerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "display_name": {
                    "type": "string"
                  },
                  "config": {
                    "type": "object"
                  },
                  "capabilities": {
                    "type": "object"
                  },
                  "priority": {
                    "type": "integer"
                  },
                  "api_url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "webhook_url": {
                    "type": "string",
                    "format": "uri"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Provider updated"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          }
        }
      },
      "delete": {
        "operationId": "deleteIntegrationProvider",
        "tags": ["Integration"],
        "summary": "Remove an integration provider (platform super_admin, with a reason)",
        "description": "A staff super_admin in the platform scope only (DEC-0042). Deletes the row and writes a platform.setting.changed audit row (setting integration_provider_deleted: person, reason, the row before) in the same transaction. finance-api reads no DELETE body, so the reason is a query parameter.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "providerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "reason",
            "in": "query",
            "required": true,
            "description": "Why (10 to 1000 characters, percent-encoded); written into the audit row of the change.",
            "schema": {
              "type": "string",
              "minLength": 10,
              "maxLength": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Provider removed: the row before"
          },
          "400": {
            "description": "reason_required: no reason of 10 to 1000 characters"
          },
          "403": {
            "description": "forbidden_role: not a super_admin in the platform scope"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/integrations/{providerId}/activate": {
      "post": {
        "operationId": "activateIntegrationProvider",
        "tags": ["Integration"],
        "summary": "Activate integration provider",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "providerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Provider activated"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          }
        }
      }
    },
    "/api/v1/integrations/{providerId}/deactivate": {
      "post": {
        "operationId": "deactivateIntegrationProvider",
        "tags": ["Integration"],
        "summary": "Deactivate integration provider",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "providerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Provider deactivated"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          }
        }
      }
    },
    "/api/v1/integrations/{providerId}/test": {
      "post": {
        "operationId": "testIntegrationProvider",
        "tags": ["Integration"],
        "summary": "Test a provider connection (platform super_admin)",
        "description": "A harmless call per provider type with a timeout: an authenticated\nread where the provider has one (sanctions.io data sources,\nTransactionLink one record page), the company key and TLS\nreachability for Identomat, TLS reachability of a public HTTPS URL\notherwise (no credentials sent), nothing for the built-in mock. A URL\nis called only on port 443, without userinfo, with a canonical IP or\na public name of two or more labels, and only when every address it\nresolves to is public; the call is pinned to the checked address. The\nresult, latency and a short fixed detail are stored on the provider\n(and its `health_status`) with an `INTEGRATION_CONNECTION_TESTED`\naudit row. Never a provider body or a secret. A super_admin staff\nsession in the platform scope (migration 285).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "providerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{success, kind: authenticated|reachability|mock|not_testable, latency_ms, detail, provider, display_name}`"
          },
          "403": {
            "description": "`forbidden_role`"
          },
          "404": {
            "description": "No such provider"
          }
        }
      }
    },
    "/api/v1/integrations/{providerId}/credential-expiry": {
      "post": {
        "operationId": "setIntegrationCredentialExpiry",
        "tags": ["Integration"],
        "summary": "When the provider credential expires (platform super_admin)",
        "description": "Audited as `INTEGRATION_CREDENTIAL_EXPIRY_SET` (migration 285).",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "providerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["expires_at", "reason"],
                "properties": {
                  "expires_at": {
                    "type": ["string", "null"],
                    "format": "date"
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`{id, secret_expires_at}`"
          },
          "400": {
            "description": "`reason_required`, `invalid_field`"
          },
          "404": {
            "description": "No such provider"
          }
        }
      }
    },
    "/api/v1/integrations/health-overview": {
      "get": {
        "operationId": "getIntegrationHealthOverview",
        "tags": ["Integration"],
        "summary": "Every provider connection with circuit state, last test and credential expiry (platform super_admin)",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "`{providers: [{id, provider_name, display_name, domain, status, tenant_id, health_status, circuit_state, circuit_failures, circuit_last_failure, last_test_at, last_test_ok, last_test_kind, last_test_latency_ms, last_test_detail, secret_ref_set, secret_expires_at}]}`"
          }
        }
      }
    },
    "/api/v1/integrations/webhook-health": {
      "get": {
        "operationId": "getWebhookDeliveryHealth",
        "tags": ["Integration"],
        "summary": "Delivery of outgoing notifications per bank (platform super_admin)",
        "description": "The last 30 days of `finance_webhook_events` per bank that is not\nterminated: whether an endpoint is set, pending, retrying, failed in\n7 days, delivered in 24 hours, last success and last failure.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "`{banks: [{tenant_id, name, status, endpoint_set, pending, retrying, failed_7d, delivered_24h, last_success_at, last_failure_at}]}`"
          }
        }
      }
    },
    "/api/v1/integrations/{providerId}/sandbox": {
      "post": {
        "operationId": "toggleProviderSandbox",
        "tags": ["Integration"],
        "summary": "Toggle sandbox mode for integration provider",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "providerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["sandbox_mode"],
                "properties": {
                  "sandbox_mode": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sandbox mode updated"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          }
        }
      }
    },
    "/api/v1/integration/health": {
      "get": {
        "operationId": "getIntegrationHealth",
        "tags": ["Integration"],
        "summary": "Integration engine health check",
        "responses": {
          "200": {
            "description": "Integration engine status"
          }
        }
      }
    },
    "/api/v1/integration/providers": {
      "get": {
        "operationId": "listProviders",
        "tags": ["Integration"],
        "summary": "List registered payment and banking providers",
        "description": "Returns all configured integration providers (SEPA SCT/SDD, SWIFT,\ncard processors, IBAN services) with their current connectivity status\nand supported capabilities.\n",
        "responses": {
          "200": {
            "description": "Provider list"
          }
        }
      }
    },
    "/api/v1/integration/iban/generate": {
      "post": {
        "operationId": "generateIban",
        "tags": ["Integration"],
        "summary": "Generate IBAN with ISO 13616 check digit validation",
        "description": "Generates a valid IBAN using a database sequence for uniqueness and\ncountry-specific formatting rules per ISO 13616. Supports 12\ncountries: DE, AT, CH, FR, NL, BE, ES, IT, GB, IE, PT, LU.\nThe generated IBAN includes a computed MOD-97 check digit pair.\nFormat: `{country}{checkDigits}PLAN{sequenceNumber}`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["country"],
                "properties": {
                  "country": {
                    "$ref": "#/components/schemas/CountryCode"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Generated IBAN"
          }
        }
      }
    },
    "/api/v1/integration/iban/validate": {
      "post": {
        "operationId": "validateIban",
        "tags": ["Integration"],
        "summary": "Validate IBAN format and check digits (ISO 13616)",
        "description": "Validates the IBAN structure, country-specific length, and MOD-97 check\ndigit per ISO 13616. Returns validation result with details on any\nformat violations detected.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["iban"],
                "properties": {
                  "iban": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Validation result"
          }
        }
      }
    },
    "/api/v1/integration/iban/registry": {
      "get": {
        "operationId": "getIbanRegistry",
        "tags": ["Integration"],
        "summary": "List all IBANs in the platform registry",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "IBAN registry"
          }
        }
      }
    },
    "/api/v1/integration/accounts/virtual": {
      "post": {
        "operationId": "createVirtualAccount",
        "tags": ["Integration"],
        "summary": "Provision virtual account via banking provider",
        "description": "Creates a virtual account through the configured banking provider.\nVirtual accounts enable receipt of inbound payments that are automatically\nattributed to the correct customer account via IBAN matching.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Virtual account created"
          }
        }
      }
    },
    "/api/v1/webhooks/events": {
      "get": {
        "operationId": "listWebhookEvents",
        "tags": ["Webhooks"],
        "summary": "List webhook events from transactional outbox",
        "description": "Returns webhook events from the outbox table with delivery\nstatus, attempt count, and timing metadata. Events are created\ntransactionally alongside the originating financial operation,\nguaranteeing at-least-once delivery semantics. Newest 100 of the\nrequest's tenant (X-Tenant-ID; a cell session's own bank); only the\nplatform scope without a tenant lists every bank's.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "503": {
            "description": "`webhooks_unavailable`: the read failed (never an empty list)"
          },
          "200": {
            "description": "Webhook events",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "events": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/WebhookEvent"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/webhooks/stats": {
      "get": {
        "operationId": "getWebhookStats",
        "tags": ["Webhooks"],
        "summary": "Retrieve webhook delivery statistics",
        "description": "Returns aggregate delivery metrics: pending, delivered, failed, and\nretrying event counts. Used for operational monitoring and alerting\non delivery degradation. Counts the request's tenant only\n(X-Tenant-ID; a cell session's own bank); only the platform scope\nwithout a tenant counts every bank's.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Delivery stats (pending, delivered, failed counts)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "pending",
                    "delivered",
                    "failed",
                    "retrying",
                    "total"
                  ],
                  "properties": {
                    "pending": {
                      "type": "integer"
                    },
                    "delivered": {
                      "type": "integer"
                    },
                    "failed": {
                      "type": "integer"
                    },
                    "retrying": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "`webhooks_unavailable`: the read failed (never zero counts)"
          }
        }
      }
    },
    "/api/v1/webhooks/events/{eventId}/retry": {
      "post": {
        "operationId": "retryWebhookEvent",
        "tags": ["Webhooks"],
        "summary": "Manually retry a failed webhook delivery",
        "description": "Requeues a failed webhook event for immediate redelivery. Resets the\nretry counter and schedules the next attempt. Use for operational\nrecovery after transient endpoint failures.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "eventId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Event queued for retry"
          }
        }
      }
    },
    "/api/v1/webhooks/process": {
      "post": {
        "operationId": "processWebhookEvents",
        "tags": ["Webhooks"],
        "summary": "Trigger batch processing of pending webhook events",
        "description": "Processes all pending webhook events in the outbox. Typically called\nby a scheduled job (cron) or manually for operational recovery. Each\nevent is delivered to the tenant's configured webhook URL with retry\non failure using exponential backoff.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Events processed"
          }
        }
      }
    },
    "/api/v1/edd-reviews": {
      "get": {
        "operationId": "listEddReviews",
        "tags": ["EddReview"],
        "summary": "The bank's enhanced due diligence queue",
        "description": "EDD reviews of the request's bank (migration 294): those waiting for\na second officer first, then open ones oldest first, then decided\nones newest first. `open_count`, `awaiting_count` and\n`decided_count` count the bank's reviews whatever `state` and\n`limit` list. Read: mlro and auditor of the bank; super_admin naming\nthe bank in X-Tenant-ID.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "state",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": ["open", "decided", "all"],
              "default": "open"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 200
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The queue",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EddReviewList"
                }
              }
            }
          },
          "400": {
            "description": "`tenant_required`"
          },
          "403": {
            "description": "`staff_session_required`, `forbidden_role`"
          },
          "422": {
            "description": "`invalid_field` (`state`, `limit`)"
          },
          "503": {
            "description": "`edd_unavailable`, `Retry-After: 5`"
          }
        }
      }
    },
    "/api/v1/edd-reviews/checklist": {
      "get": {
        "operationId": "getEddChecklist",
        "tags": ["EddReview"],
        "summary": "The bank's EDD checklist template",
        "description": "The checklist a new review of this bank gets: the bank's own list\n(`source: bank`) or the platform defaults (`source: platform`),\nwith the defaults and the mandatory items. Read: mlro, auditor,\nsuper_admin.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The template",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EddChecklist"
                }
              }
            }
          },
          "403": {
            "description": "`staff_session_required`, `forbidden_role`"
          }
        }
      },
      "put": {
        "operationId": "putEddChecklist",
        "tags": ["EddReview"],
        "summary": "Replace the bank's EDD checklist template",
        "description": "The bank's MLRO sets its own list (new reviews only; open reviews\nkeep theirs). Source of wealth, source of funds and senior\nmanagement approval stay required (`edd_checklist_floor`). A bank's\nown item needs a label; a default item may keep the portal's\ntranslation. An empty list returns the bank to the platform\ndefaults. Audit `edd_checklist_changed`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EddChecklistUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The template as saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EddChecklist"
                }
              }
            }
          },
          "403": {
            "description": "`staff_session_required`, `forbidden_role`, `person_required`"
          },
          "422": {
            "description": "`edd_checklist_floor`, `label_required`, `invalid_field` and the text codes, with `field`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/edd-reviews/customer/{customerId}": {
      "parameters": [
        {
          "name": "customerId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "get": {
        "operationId": "listCustomerEddReviews",
        "tags": ["EddReview"],
        "summary": "A customer's EDD reviews (the KYC card)",
        "description": "Status only, newest first, and the review not yet decided: the\ncustomer page says \"Enhanced due diligence open\" and links it.\nEvery non-support role of the bank and super_admin, as the\ncustomer's screening results.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The customer's reviews",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EddCustomerReviews"
                }
              }
            }
          },
          "403": {
            "description": "`staff_session_required`, `forbidden_role`"
          }
        }
      }
    },
    "/api/v1/edd-reviews/{reviewId}": {
      "parameters": [
        {
          "name": "reviewId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "get": {
        "operationId": "getEddReview",
        "tags": ["EddReview"],
        "summary": "One EDD review with everything inline",
        "description": "Why it was opened (the confirmed match), the customer, the\nchecklist, attached documents and the customer's other CDD\nregister documents, ongoing screening, the screening result, the\nhistory, what each decision does (`consequences`) and what the\nviewer may do (`viewer`).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The review",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EddReviewDetail"
                }
              }
            }
          },
          "404": {
            "description": "`not_found` (also another bank's review)"
          }
        }
      }
    },
    "/api/v1/edd-reviews/{reviewId}/items/{itemKey}": {
      "parameters": [
        {
          "name": "reviewId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        },
        {
          "name": "itemKey",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]{1,47}$"
          }
        }
      ],
      "post": {
        "operationId": "updateEddReviewItem",
        "tags": ["EddReview"],
        "summary": "Mark a checklist item",
        "description": "`done` or `not_applicable` with a note of what was collected or why\nit does not apply (10 to 2000 characters); `open` again. A required\nitem is never `not_applicable`. Only while the review is open; the\nbank's MLRO. Event `item_updated`; audit `edd_updated`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EddItemUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The review",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EddReviewDetail"
                }
              }
            }
          },
          "403": {
            "description": "`staff_session_required`, `forbidden_role`, `person_required`"
          },
          "404": {
            "description": "`not_found`"
          },
          "409": {
            "description": "`edd_not_open`"
          },
          "422": {
            "description": "`edd_unknown_item`, `edd_item_required`, `invalid_field` and the text codes"
          }
        }
      }
    },
    "/api/v1/edd-reviews/{reviewId}/notes": {
      "parameters": [
        {
          "name": "reviewId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "post": {
        "operationId": "addEddReviewNote",
        "tags": ["EddReview"],
        "summary": "A note in the review's history",
        "description": "While the review is open or waits for a decision; the bank's MLRO.\nEvent `note`; audit `edd_updated` (without the text).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EddNote"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The review",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EddReviewDetail"
                }
              }
            }
          },
          "409": {
            "description": "`edd_not_open`"
          },
          "422": {
            "description": "the text codes, with `field`"
          }
        }
      }
    },
    "/api/v1/edd-reviews/{reviewId}/documents": {
      "parameters": [
        {
          "name": "reviewId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "post": {
        "operationId": "attachEddReviewDocument",
        "tags": ["EddReview"],
        "summary": "Attach a document of the customer's CDD register",
        "description": "A document the customer sent (a request on a kyc ticket, accepted\ninto `finance_cdd_document`), optionally to one checklist item.\nOnly the review's customer's documents; only while the review is\nopen. Event `document_attached`; audit `edd_updated`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EddDocumentAttach"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The review",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EddReviewDetail"
                }
              }
            }
          },
          "409": {
            "description": "`edd_not_open`, `edd_document_attached`"
          },
          "422": {
            "description": "`edd_document_not_found`, `edd_unknown_item`, `invalid_field`"
          }
        }
      }
    },
    "/api/v1/edd-reviews/{reviewId}/submit": {
      "parameters": [
        {
          "name": "reviewId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "post": {
        "operationId": "submitEddReview",
        "tags": ["EddReview"],
        "summary": "Recommend a decision (the maker)",
        "description": "The officer who worked the review recommends `approve` (every\nrequired item done) or `reject` with what follows (`offboard` or\n`restrict`) and why. The review then waits for a second officer.\nEvent `submitted`; audit `edd_submitted`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EddSubmit"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The review",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EddReviewDetail"
                }
              }
            }
          },
          "409": {
            "description": "`edd_not_open`, `edd_checklist_incomplete`"
          },
          "422": {
            "description": "`invalid_field` and the text codes"
          }
        }
      }
    },
    "/api/v1/edd-reviews/{reviewId}/decide": {
      "parameters": [
        {
          "name": "reviewId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "post": {
        "operationId": "decideEddReview",
        "tags": ["EddReview"],
        "summary": "Decide a review (a second officer)",
        "description": "A second MLRO of the bank, never the officer who recommended\n(four-eyes, also in the database), confirms the recommendation or\nreturns the review. `approve`: the customer's screening becomes\n`clear` (outcome `cleared`; `still_held` while another review or an\nopen screening result holds it); the risk level stays high.\n`reject` `offboard`: an active or suspended customer goes to closure\nfor cause (`aml_pep_risk`, outcome `closure_initiated`), an\nonboarding customer gets the KYC rejected whatever its KYC status\n(`kyc_rejected`); offboarding never leaves the customer held.\n`restrict`: an active customer is suspended and its accounts frozen\n(`suspended`); otherwise `held`. A rejected customer's screening is\nnever cleared, unless a new review (`/reopen`) is approved.\n`return`: back to the maker. A decided review is final. Audit\n`edd_approved`, `edd_rejected` or `edd_returned`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EddDecide"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The review",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EddReviewDetail"
                }
              }
            }
          },
          "403": {
            "description": "`edd_second_officer_required`, `forbidden_role`, `person_required`"
          },
          "409": {
            "description": "`edd_not_awaiting_decision`, `edd_decision_differs`, `edd_checklist_incomplete`, `edd_decided`, `edd_consequence_failed`"
          },
          "422": {
            "description": "`invalid_field` and the text codes"
          }
        }
      }
    },
    "/api/v1/edd-reviews/{reviewId}/reopen": {
      "parameters": [
        {
          "name": "reviewId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "post": {
        "operationId": "reopenEddReview",
        "tags": ["EddReview"],
        "summary": "Open a new review after a rejected one",
        "description": "The bank's MLRO opens a new review of the same confirmed match with\na reason (new evidence, a changed situation). It starts open with a\nfresh checklist and again needs a second officer; only its approval\nclears the customer. One new review per rejected review. Events\n`reopened` (new) and `superseded` (rejected); audit `edd_opened`\n(`edd.reopened`).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["reason"],
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 10,
                    "maxLength": 4000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The new review",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EddReviewDetail"
                }
              }
            }
          },
          "403": {
            "description": "`staff_session_required`, `forbidden_role`, `person_required`"
          },
          "404": {
            "description": "`not_found`"
          },
          "409": {
            "description": "`edd_not_rejected`, `edd_already_reopened`"
          },
          "422": {
            "description": "the text codes, with `field`"
          }
        }
      }
    },
    "/api/v1/ict-incidents": {
      "get": {
        "operationId": "listIctIncidents",
        "tags": ["IctRisk"],
        "summary": "The bank's ICT incident register",
        "description": "Incidents of the request's bank, open first with the nearest unmet\nreporting deadline first, then closed ones by closing time.\n`open_count`, `closed_count` and `overdue_count` count the whole\nregister whatever `state` and `limit` list. Read: bank_admin, mlro,\ncoo, auditor of the bank; super_admin naming the bank in\nX-Tenant-ID.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "state",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": ["open", "closed", "all"],
              "default": "all"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 200
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The register",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IctIncidentList"
                }
              }
            }
          },
          "400": {
            "description": "`tenant_required`"
          },
          "403": {
            "description": "`staff_session_required`, `forbidden_role`"
          },
          "422": {
            "description": "`invalid_field` (`state`, `limit`)"
          },
          "503": {
            "description": "`ict_unavailable`, `Retry-After: 5`"
          }
        }
      },
      "post": {
        "operationId": "createIctIncident",
        "tags": ["IctRisk"],
        "summary": "Log an ICT incident",
        "description": "A new incident, status `open`. The regime (`EU` or `CH`) follows\nthe bank's home regime. bank_admin, mlro or coo of the\nbank; the actor is the session's staff member. Audit\n`ict_incident_created`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IctIncidentCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The incident with its timeline",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IctIncident"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_json`, `tenant_required`"
          },
          "403": {
            "description": "`staff_session_required`, `forbidden_role`, `person_required`"
          },
          "422": {
            "description": "`blank`, `too_short`, `too_long`, `invalid_characters`, `invalid_field` with `field`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          },
          "503": {
            "description": "`ict_unavailable`"
          }
        }
      }
    },
    "/api/v1/ict-incidents/{incidentId}": {
      "parameters": [
        {
          "name": "incidentId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "get": {
        "operationId": "getIctIncident",
        "tags": ["IctRisk"],
        "summary": "One ICT incident with its timeline",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The incident",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IctIncident"
                }
              }
            }
          },
          "404": {
            "description": "`not_found` (also another bank's incident)"
          }
        }
      },
      "patch": {
        "operationId": "updateIctIncident",
        "tags": ["IctRisk"],
        "summary": "Change what the officer described",
        "description": "Title, description, affected services, `detected_at` (only while\nthe incident is not classified: the deadlines run from it), and the\nCH flags. Event `updated`; audit `ict_incident_updated`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IctIncidentUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The incident",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IctIncident"
                }
              }
            }
          },
          "409": {
            "description": "`incident_closed`, `detected_at_fixed`"
          },
          "422": {
            "description": "`invalid_field` and the text codes, with `field`"
          }
        }
      }
    },
    "/api/v1/ict-incidents/{incidentId}/classify": {
      "parameters": [
        {
          "name": "incidentId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "post": {
        "operationId": "classifyIctIncident",
        "tags": ["IctRisk"],
        "summary": "Classify an ICT incident (major, significant, minor)",
        "description": "Sets or changes the classification and the criteria it rests on\n(Delegated Regulation (EU) 2024/1772). `classified_at` moves only\nwhen the classification changes. The deadlines run from\n`reportable_since`, when the incident first entered a class with\nreporting duties; it never moves, so a reclassification neither\nrestarts a deadline nor withdraws one. Deadlines: CH\nmajor or significant: FINMA initial notice 24 h and report via EHP\n72 h after the first classification as significant or major; NCSC\n24 h after detection for a cyber attack; FDPIC as soon as possible\nfor a personal data breach.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IctIncidentClassify"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The incident with its deadlines",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IctIncident"
                }
              }
            }
          },
          "409": {
            "description": "`incident_closed`"
          },
          "422": {
            "description": "`invalid_field` with `field`"
          }
        }
      }
    },
    "/api/v1/ict-incidents/{incidentId}/reports": {
      "parameters": [
        {
          "name": "incidentId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "post": {
        "operationId": "recordIctIncidentReport",
        "tags": ["IctRisk"],
        "summary": "Record a report sent to an authority",
        "description": "`initial`, `intermediate` and `final` need a classification and go\nin order (initial = FINMA initial notice,\nintermediate = FINMA report via EHP); `ncsc` and\n`fdpic` are for CH banks. A report is\nrecorded once and never changes. `reported_at` is not before\ndetection and not in the future.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IctIncidentReport"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The incident",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IctIncident"
                }
              }
            }
          },
          "409": {
            "description": "`incident_closed`, `not_classified`, `report_recorded`, `report_order`"
          },
          "422": {
            "description": "`report_not_applicable`, `invalid_field` (`kind`, `reported_at`)"
          }
        }
      }
    },
    "/api/v1/ict-incidents/{incidentId}/close": {
      "parameters": [
        {
          "name": "incidentId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "post": {
        "operationId": "closeIctIncident",
        "tags": ["IctRisk"],
        "summary": "Close an ICT incident with its root cause and resolution",
        "description": "The incident must be classified and every report that applies\nrecorded. `root_cause_resolution` 10 to 4000 characters. A closed\nincident is final.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["root_cause_resolution"],
                "properties": {
                  "root_cause_resolution": {
                    "type": "string",
                    "minLength": 10,
                    "maxLength": 4000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The closed incident",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IctIncident"
                }
              }
            }
          },
          "409": {
            "description": "`incident_closed`, `not_classified`, `reports_due`"
          },
          "422": {
            "description": "`too_short`, `blank`, `too_long`, `invalid_characters`"
          }
        }
      }
    },
    "/api/v1/ict-third-parties": {
      "get": {
        "operationId": "listIctThirdParties",
        "tags": ["IctRisk"],
        "summary": "The bank's ICT third-party register",
        "description": "Read: bank_admin, coo, auditor of the bank; super_admin naming the\nbank in X-Tenant-ID.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The register",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["providers", "critical_count"],
                  "properties": {
                    "providers": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/IctThirdParty"
                      }
                    },
                    "critical_count": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`staff_session_required`, `forbidden_role`"
          }
        }
      },
      "post": {
        "operationId": "createIctThirdParty",
        "tags": ["IctRisk"],
        "summary": "Add a row to the ICT third-party register",
        "description": "bank_admin or coo of the bank. One row per provider and service. A\nservice that supports a critical or important function needs an\nexit plan.\nAudit `ict_third_party_created`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IctThirdPartyInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The row",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IctThirdParty"
                }
              }
            }
          },
          "409": {
            "description": "`duplicate`"
          },
          "422": {
            "description": "`exit_plan_required`, `invalid_field`, text codes, with `field`"
          }
        }
      }
    },
    "/api/v1/ict-third-parties/{rowId}": {
      "parameters": [
        {
          "name": "rowId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "patch": {
        "operationId": "updateIctThirdParty",
        "tags": ["IctRisk"],
        "summary": "Replace a register row's fields",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IctThirdPartyInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The row",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IctThirdParty"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`"
          },
          "409": {
            "description": "`duplicate`"
          },
          "422": {
            "description": "`exit_plan_required`, `invalid_field`"
          }
        }
      },
      "delete": {
        "operationId": "deleteIctThirdParty",
        "tags": ["IctRisk"],
        "summary": "Remove a register row",
        "description": "Audit `ict_third_party_deleted`.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "`{\"deleted\": true}`"
          },
          "404": {
            "description": "`not_found`"
          }
        }
      }
    },
    "/api/v1/audit": {
      "get": {
        "operationId": "listAuditEvents",
        "tags": ["Audit"],
        "summary": "List hash-chained audit events",
        "description": "Returns the tamper-evident audit trail ordered by creation time.\nEach event includes a SHA-256 hash computed over the event payload\nconcatenated with the previous event's hash, forming an append-only\nchain. Chain integrity can be verified by recomputing hashes\nsequentially. Designed to support ICT risk, incident, and AML\nrecord-keeping controls (FINMA Circular 2023/1, AMLA Art. 7), subject to\noperational implementation and legal validation.\n\nAccess: a session in the explicit platform scope (super_admin) reads\nevery tenant, or the one named in `X-Tenant-ID`. Inside a cell the\npolicies `bank_admin`, `mlro`, `auditor`, `coo` and `cfo` read only\nthe session's tenant (another `X-Tenant-ID` is 403). Customers and\nother roles get 403. The same rules apply to `/audit/entity/...`,\n`/audit/stats` and `/audit/export`; `/audit/verify-chain` is platform\nor service only. A platform-scope operator never gets a bank's SAR\nrows (no-SAR decisions; SAR created, updated, submitted, exported;\nentity `sar`), nor rows of hidden support cases, in the list, the\ncount, the stats, by entity or in the export (Super-Admin audit\n2026-10-06 S8, review M4).\n\nPaging and filters run in SQL: `total` counts the rows the filters\nmatch (not the page), up to 10,000 (`total_capped` beyond); with\n`count=none` it is left out (null), so a portal counts once per\nfilter through `/audit/count` instead of on every page. Absent\nparameters do not filter; a parameter that does not parse is 400\n`invalid_filter` with the `field`. A search (`q` or `actor`) runs\nwith a 3 s statement timeout: past it, 422 `search_timeout` (narrow\nthe dates). Without `limit` a request gets the latest 100 rows.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 100
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 1000000,
              "default": 0
            }
          },
          {
            "name": "from",
            "in": "query",
            "description": "Unix seconds, inclusive.",
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "Unix seconds, inclusive (the whole second); not before `from`.",
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "event_type",
            "in": "query",
            "description": "Comma-separated event codes (audit.zig EventType); any of them.",
            "schema": {
              "type": "string",
              "example": "100,104"
            }
          },
          {
            "name": "entity_type",
            "in": "query",
            "description": "Entity code (audit.zig EntityType).",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "entity_id",
            "in": "query",
            "description": "The entity id as stored (lower-case hex, up to 32 digits).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "actor",
            "in": "query",
            "description": "Part of the actor id or of `data.actor` (the officer), any case. Up to 200 bytes.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "in": "query",
            "description": "Part of the action, entity id, actor id, event hash, row id or\ndata, any case; `%` and `_` match themselves. Up to 200 bytes.\n",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q_event_type",
            "in": "query",
            "description": "Comma-separated event codes whose label the portal matched to `q`; rows with them also match `q`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "count",
            "in": "query",
            "description": "`none`: leave the count out (`total` null).",
            "schema": {
              "type": "string",
              "enum": ["none"]
            }
          }
        ],
        "responses": {
          "400": {
            "description": "`invalid_filter`: a parameter does not parse (`field` names it)"
          },
          "403": {
            "description": "Role not allowed, or `X-Tenant-ID` other than the session tenant"
          },
          "422": {
            "description": "`search_timeout`: a text or actor search ran past 3 s"
          },
          "200": {
            "description": "One page of audit events, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "entries": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/AuditEvent"
                      }
                    },
                    "total": {
                      "type": ["integer", "null"],
                      "description": "Rows the filters match, up to 10,000; null with count=none"
                    },
                    "total_capped": {
                      "type": "boolean",
                      "description": "More than 10,000 rows match"
                    },
                    "limit": {
                      "type": "integer"
                    },
                    "offset": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/audit/count": {
      "get": {
        "operationId": "countAuditEvents",
        "tags": ["Audit"],
        "summary": "Count the audit events a filter matches",
        "description": "The filters of `GET /api/v1/audit` (limit and offset do not apply),\ncounted up to 10,000; `capped` beyond. Access, `invalid_filter` and\n`search_timeout` as `GET /api/v1/audit`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "400": {
            "description": "`invalid_filter`"
          },
          "403": {
            "description": "Role not allowed, or `X-Tenant-ID` other than the session tenant"
          },
          "422": {
            "description": "`search_timeout`"
          },
          "200": {
            "description": "Bounded count",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total": {
                      "type": "integer"
                    },
                    "capped": {
                      "type": "boolean"
                    },
                    "cap": {
                      "type": "integer",
                      "example": 10000
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/audit/export": {
      "get": {
        "operationId": "exportAuditEvents",
        "tags": ["Audit"],
        "summary": "Regulatory export of the audit log by date range",
        "description": "Every row created from `from` to `to` (unix seconds, both inclusive,\n`to` the whole second), in chain order, with every field that feeds\nthe hash. At most 5,000 rows per response: a larger range answers\n`truncated: true` with `next_after_seq` (chain_seq of the last row\nreturned) and `next_from` (unix seconds of the first row not\nreturned, for display). Ask again with the same range and\n`after_seq=next_after_seq`: each row comes exactly once, also when\nmore than 5,000 rows share one second. Access as `GET /api/v1/audit`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "after_seq",
            "in": "query",
            "description": "The next part of a truncated export (`next_after_seq`).",
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "400": {
            "description": "A timestamp or `after_seq` does not parse"
          },
          "403": {
            "description": "Role not allowed, or `X-Tenant-ID` other than the session tenant"
          },
          "200": {
            "description": "One part of the export",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "entries": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": true
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "limit": {
                      "type": "integer"
                    },
                    "truncated": {
                      "type": "boolean"
                    },
                    "next_after_seq": {
                      "type": "integer",
                      "format": "int64"
                    },
                    "next_from": {
                      "type": "integer",
                      "format": "int64"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/audit/stats": {
      "get": {
        "operationId": "getAuditStats",
        "tags": ["Audit"],
        "summary": "Count today's audit events",
        "description": "The tenant's rows since `since` (every tenant in the platform view),\nthe caller's local midnight: the audit log's \"Today\" figure, counted\nup to 10,000 (`since_capped` beyond). Access as `GET /api/v1/audit`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "since",
            "in": "query",
            "description": "Unix seconds; default 0.",
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "400": {
            "description": "`invalid_filter` (`field`: `since`)"
          },
          "403": {
            "description": "Role not allowed, or `X-Tenant-ID` other than the session tenant"
          },
          "200": {
            "description": "Counts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "since": {
                      "type": "integer",
                      "description": "Rows created at or after `since_ts`, up to 10,000"
                    },
                    "since_capped": {
                      "type": "boolean"
                    },
                    "since_ts": {
                      "type": "integer",
                      "format": "int64"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/audit/entity/{entityType}/{entityId}": {
      "get": {
        "operationId": "getAuditByEntity",
        "tags": ["Audit"],
        "summary": "Retrieve audit trail for a specific entity",
        "description": "Returns all audit events associated with a specific entity (account,\ncustomer, tenant, transfer, etc.). Entity type is specified as a\nnumeric enum; entity ID as a hex-encoded 128-bit identifier. Used\nfor incident investigation, compliance reporting, and dispute resolution.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "entityType",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "wallet",
                "account",
                "transfer",
                "customer",
                "tenant",
                "fx"
              ]
            }
          },
          {
            "name": "entityId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Entity audit trail"
          }
        }
      }
    },
    "/workflows/discover": {
      "get": {
        "operationId": "workflowDiscover",
        "tags": ["Integration"],
        "summary": "Durable execution service discovery",
        "description": "Returns the list of available durable execution services and their\ninvocable methods. The workflow engine provides exactly-once execution\nguarantees for long-running financial workflows (account opening,\npayment orchestration, reconciliation).\n",
        "responses": {
          "200": {
            "description": "Available workflow services"
          }
        }
      }
    },
    "/workflows/invoke/{method}": {
      "post": {
        "operationId": "workflowInvoke",
        "tags": ["Integration"],
        "summary": "Invoke durable execution method",
        "description": "Invokes a workflow method with automatic retry, compensation, and\nexactly-once execution semantics. Used for orchestrating multi-step\nfinancial workflows that require transactional guarantees across\nmultiple systems (ledger, database, external providers).\n",
        "parameters": [
          {
            "name": "method",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Invocation result"
          }
        }
      }
    },
    "/workflows/events": {
      "get": {
        "operationId": "workflowEvents",
        "tags": ["Integration"],
        "summary": "Workflow event stream",
        "description": "Returns recent durable execution events for monitoring and debugging\nlong-running financial workflows.\n",
        "responses": {
          "200": {
            "description": "Recent events"
          }
        }
      }
    },
    "/api/v1/reports/woff-summary": {
      "get": {
        "operationId": "getWoffSummary",
        "tags": ["Reports"],
        "summary": "WOFF/NPE aggregate statistics",
        "description": "Returns aggregate statistics for the tenant's written-off accounts:\nthe number of accounts, then per currency the accounts, write-off\namount, recovered amount and recovery rate, the breakdown by IFRS 9\nreason (bad_debt, fraud, deceased, bankruptcy, regulatory) per\ncurrency, and the payments blocked on these accounts in the last 30\ndays. Amounts are minor units of their currency and are never summed\nacross currencies. `outstanding` per currency is what is written off\nand not recovered (never below zero per account). `from` and `to`\nlimit the report to write-offs in a period: business days of the\nwrite-off in the bank's time zone (its jurisdiction's, else UTC),\nboth inclusive, each optional. A bank session reads its own bank; the platform\nscope reads the bank named in `X-Tenant-ID`, or every bank without it.\nSupports recovery monitoring.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WoffPeriodFrom"
          },
          {
            "$ref": "#/components/parameters/WoffPeriodTo"
          }
        ],
        "responses": {
          "400": {
            "description": "`{\"error\":\"invalid_date\"}`: `from` or `to` is not a calendar day (YYYY-MM-DD), or `from` is after `to`"
          },
          "200": {
            "description": "WOFF summary statistics",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WoffSummary"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          }
        }
      }
    },
    "/api/v1/reports/woff-accounts": {
      "get": {
        "operationId": "getWoffAccounts",
        "tags": ["Reports"],
        "summary": "List written-off accounts with recovery progress",
        "description": "Returns one page of the tenant's accounts in `woff` status with their\nwrite-off details: the customer whose account it is (`customer_id`,\n`customer_name`; null for an account without a customer), reason,\ndate, original amount, recovered amount, `outstanding` (written off\nand not recovered, never below zero), ISO 20022 return code, and\ncurrency (minor units of that currency). `from` and `to`: the period,\nas on the summary. Ordered by write-off date (newest first); `total`\ncounts every written-off account in the period. A bank session reads its bank; the platform\nscope reads the bank named in `X-Tenant-ID`, or every bank without\nit (each row names its bank: `tenant_id`, `tenant_name`). Used for\nNPE portfolio monitoring and recovery team workload management.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 1000000,
              "default": 0
            }
          },
          {
            "$ref": "#/components/parameters/WoffPeriodFrom"
          },
          {
            "$ref": "#/components/parameters/WoffPeriodTo"
          }
        ],
        "responses": {
          "400": {
            "description": "`invalid_page`: limit or offset out of range; `invalid_date`: `from` or `to` is not a calendar day, or `from` is after `to`"
          },
          "200": {
            "description": "WOFF account list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WoffAccountList"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          }
        }
      }
    },
    "/api/v1/beneficiaries": {
      "get": {
        "operationId": "listBeneficiaries",
        "tags": ["Beneficiaries"],
        "summary": "List saved payment beneficiaries",
        "description": "Customer JWT: returns the JWT customer's payees. `customer_id` may be\nomitted (defaults to the JWT customer); any other value returns 403\n`forbidden`. `tenant_id` returns 403 `forbidden`. A customer JWT reads\n`verification_status` only as `verified` or `pending` (a\n`sanctions_flagged` or `failed` payee reads `pending`) and\n`verified_by`, `verification_source` and `verification_ref` as null,\non every /beneficiaries and /payees answer (no tipping-off).\n\nAdmin session or `X-Service-Key`: filter by `customer_id` or\n`tenant_id` (max 200 rows); one of them is required.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "customer_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Owning customer. Customer JWTs may only pass their own id."
          },
          {
            "name": "tenant_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Tenant-wide view. Admin session and service key only."
          }
        ],
        "responses": {
          "200": {
            "description": "Beneficiary list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "beneficiaries": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Beneficiary"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BeneficiaryBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/BeneficiaryForbidden"
          }
        }
      },
      "post": {
        "operationId": "createBeneficiary",
        "tags": ["Beneficiaries"],
        "summary": "Create a saved beneficiary",
        "description": "Creates a new saved payment recipient. Either `iban` or both\n`account_number` and `routing_number` are required. The IBAN is\nstored without spaces and upper-case after an ISO 13616 mod-97 check.\nAfter creation the beneficiary is screened against the sanctions list\nif screening is enabled for the tenant (BR-EF-026). Screening failure\nis non-blocking.\n\nCustomer JWT: `customer_id` and `tenant_id` come from the JWT. A body\nvalue that differs returns 403 `forbidden`; omitting them is fine.\nRole must be `owner`, `admin` or `customer` (else 403\n`forbidden_role`); an impersonation session returns 403\n`read_only_session`.\n\nAdmin session or `X-Service-Key`: `customer_id` is required in the\nbody; `tenant_id` from the body or `X-Tenant-ID`. When both are set\nand differ, or the customer does not belong to that tenant, the call\nreturns 403 `forbidden`.\n\nRe-creating a payee whose deleted predecessor (same customer, same\nIBAN or account plus routing) was `sanctions_flagged` keeps that\nstatus.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateBeneficiaryRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Beneficiary created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Beneficiary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BeneficiaryBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/BeneficiaryForbidden"
          },
          "409": {
            "$ref": "#/components/responses/BeneficiaryDuplicate"
          }
        }
      }
    },
    "/api/v1/beneficiaries/{beneficiaryId}": {
      "get": {
        "operationId": "getBeneficiary",
        "tags": ["Beneficiaries"],
        "summary": "Get beneficiary by ID",
        "description": "Customer JWT: 404 `not_found` when the payee does not exist or belongs\nto another customer (existence is not disclosed).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/BeneficiaryId"
          }
        ],
        "responses": {
          "200": {
            "description": "Beneficiary details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Beneficiary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BeneficiaryBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/BeneficiaryForbidden"
          },
          "404": {
            "$ref": "#/components/responses/BeneficiaryNotFound"
          }
        }
      },
      "put": {
        "operationId": "updateBeneficiary",
        "tags": ["Beneficiaries"],
        "summary": "Update beneficiary details",
        "description": "Partial update: omitted fields keep their value. `customer_id`,\n`tenant_id` and `contact_id` cannot be changed. Changing `name`,\n`country`, `iban`, `bic`, `account_number` or `routing_number` resets\n`verification_status` to `pending` and records a verification event;\n`sanctions_flagged` is never cleared by an edit (use `/verify`).\nMoving onto the IBAN or account of a deleted `sanctions_flagged`\npayee of the same customer sets `sanctions_flagged`.\n\nCustomer JWT: same role and session rules as create; 404 `not_found`\nfor another customer's payee.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/BeneficiaryId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateBeneficiaryRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Beneficiary updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Beneficiary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BeneficiaryBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/BeneficiaryForbidden"
          },
          "404": {
            "$ref": "#/components/responses/BeneficiaryNotFound"
          },
          "409": {
            "$ref": "#/components/responses/BeneficiaryDuplicate"
          }
        }
      },
      "delete": {
        "operationId": "deleteBeneficiary",
        "tags": ["Beneficiaries"],
        "summary": "Delete beneficiary",
        "description": "Soft-deletes when the payee is referenced by a transfer, a\nverification event or a linked contact; hard-deletes otherwise.\n\nCustomer JWT: same role and session rules as create; 404 `not_found`\nfor another customer's payee.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/BeneficiaryId"
          }
        ],
        "responses": {
          "200": {
            "description": "Beneficiary deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deleted": {
                      "type": "boolean",
                      "enum": [true]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BeneficiaryBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/BeneficiaryForbidden"
          },
          "404": {
            "$ref": "#/components/responses/BeneficiaryNotFound"
          }
        }
      }
    },
    "/api/v1/beneficiaries/{beneficiaryId}/verify": {
      "post": {
        "operationId": "verifyBeneficiary",
        "tags": ["Beneficiaries"],
        "summary": "Update beneficiary verification status",
        "description": "Records the result of an external verification check (e.g. micro-deposit,\nbank account validation service). Sets the `verification_status` and\nrecords the performer and source for audit purposes.\n\nAdmin session and `X-Service-Key` only. Customer JWTs get 403\n`forbidden`. Staff (DEC-0043): `bank_admin` and the platform\n`super_admin` (403 `forbidden_role` otherwise). For an admin session\nthe performer is the session's officer; `performed_by` is read only\nfrom a service call.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/BeneficiaryId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["verification_status"],
                "properties": {
                  "verification_status": {
                    "type": "string",
                    "enum": [
                      "pending",
                      "verified",
                      "failed",
                      "sanctions_flagged"
                    ]
                  },
                  "performed_by": {
                    "type": "string",
                    "description": "Service calls only. Ignored for an admin session"
                  },
                  "verification_source": {
                    "type": "string"
                  },
                  "verification_ref": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Verification status updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Beneficiary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/BeneficiaryForbidden"
          },
          "404": {
            "$ref": "#/components/responses/BeneficiaryNotFound"
          }
        }
      }
    },
    "/api/v1/beneficiaries/{beneficiaryId}/verification-history": {
      "get": {
        "operationId": "getBeneficiaryVerificationHistory",
        "tags": ["Beneficiaries"],
        "summary": "Get verification history for a beneficiary",
        "description": "Returns up to 50 verification status changes for the beneficiary\nordered by timestamp descending. Used for compliance audit and\ndispute resolution.\n\nAdmin session and `X-Service-Key` only. Customer JWTs get 403\n`forbidden`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/BeneficiaryId"
          }
        ],
        "responses": {
          "200": {
            "description": "Verification history",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "events": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "beneficiary_id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "previous_status": {
                            "type": "string"
                          },
                          "new_status": {
                            "type": "string"
                          },
                          "performed_by": {
                            "type": "string"
                          },
                          "verification_source": {
                            "type": "string"
                          },
                          "verification_ref": {
                            "type": "string"
                          },
                          "notes": {
                            "type": "string"
                          },
                          "created_at": {
                            "type": "string",
                            "format": "date-time"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BeneficiaryBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/BeneficiaryForbidden"
          }
        }
      }
    },
    "/api/v1/payees": {
      "get": {
        "operationId": "listPayees",
        "tags": ["Payees"],
        "summary": "List payees with their accounts",
        "description": "Customer JWT: the JWT customer's payees (`customer_id` may be omitted;\nanother value returns 403 `forbidden`, `tenant_id` returns 403).\n`verification_status` reads `verified` or `pending` for a customer JWT,\nas on /beneficiaries.\nAdmin session or `X-Service-Key`: `customer_id` is required.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "customer_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Payee list, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "payees": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Payee"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BeneficiaryBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/BeneficiaryForbidden"
          }
        }
      },
      "post": {
        "operationId": "createPayee",
        "tags": ["Payees"],
        "summary": "Create a payee with its first account",
        "description": "Body as `POST /api/v1/beneficiaries` plus optional `scheme`. The first\naccount is the default for its currency. `customer_id` and\n`tenant_id` follow the beneficiary rules.\nCustomer JWT: role `owner`, `admin` or `customer` (else 403\n`forbidden_role`); impersonation returns 403 `read_only_session`;\nanother customer's payee returns 404 `not_found`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreatePayeeRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Payee created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Payee"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BeneficiaryBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/BeneficiaryForbidden"
          },
          "409": {
            "$ref": "#/components/responses/BeneficiaryDuplicate"
          }
        }
      }
    },
    "/api/v1/payees/{payeeId}": {
      "get": {
        "operationId": "getPayee",
        "tags": ["Payees"],
        "summary": "Get one payee with its accounts",
        "description": "The id must be the payee's root account; a linked account id returns\n404 `not_found`, as does another customer's payee.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "payeeId",
            "in": "path",
            "required": true,
            "description": "Payee id (the root account row). A malformed value returns 400 `invalid_id`.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Payee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Payee"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BeneficiaryBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/BeneficiaryForbidden"
          },
          "404": {
            "$ref": "#/components/responses/BeneficiaryNotFound"
          }
        }
      },
      "put": {
        "operationId": "updatePayee",
        "tags": ["Payees"],
        "summary": "Edit the payee's party fields",
        "description": "Only `type`, `name`, `country`, `address_line1`, `address_line2`,\n`city`, `postal_code`, `email` and `notes` are read; omitted fields\nkeep their value. The fields are written to every account row of the\npayee in one statement. A `name` or `country` change resets\n`verification_status` to `pending` on each affected row, records a\nverification event per row (`verification_source = payee_edit`) and\nre-screens every row; `sanctions_flagged` is never cleared.\nCustomer JWT: role `owner`, `admin` or `customer` (else 403\n`forbidden_role`); impersonation returns 403 `read_only_session`;\nanother customer's payee returns 404 `not_found`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "payeeId",
            "in": "path",
            "required": true,
            "description": "Payee id (the root account row). A malformed value returns 400 `invalid_id`.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PayeePartyRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Payee updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Payee"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BeneficiaryBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/BeneficiaryForbidden"
          },
          "404": {
            "$ref": "#/components/responses/BeneficiaryNotFound"
          }
        }
      },
      "delete": {
        "operationId": "deletePayee",
        "tags": ["Payees"],
        "summary": "Delete the payee and all its accounts",
        "description": "Each account row is soft-deleted when referenced (transfer,\nverification event), hard-deleted otherwise.\nWith `expected_accounts` the delete goes ahead only when the guard\nmatches the payee's accounts at the time of the delete; otherwise\n409 `payee_changed` and nothing is deleted. On the first send (no\n`X-SCA-Token`) the server checks the guard before starting an SCA\nchallenge, so a stale guard does not spend an approval; it checks\nagain under a lock on the payee's rows in the transaction of the\ndelete, and that check decides. Without the parameter every account\nthe payee has at that time is deleted.\nCustomer JWT: role `owner`, `admin` or `customer` (else 403\n`forbidden_role`); impersonation returns 403 `read_only_session`;\nanother customer's payee returns 404 `not_found`. The SCA approval\n(`account_change`, action `payee_remove`) names the payee id; it does\nnot cover `expected_accounts`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "payeeId",
            "in": "path",
            "required": true,
            "description": "Payee id (the root account row). A malformed value returns 400 `invalid_id`.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "expected_accounts",
            "in": "query",
            "required": false,
            "description": "Guard of the accounts the customer confirmed: the lower-case hex\nSHA-256 of their ids (the `accounts[].id` of\n`GET /api/v1/payees/{payeeId}`, the payee id included), each in\nlower case, sorted in byte order and joined by `,` without\nspaces. Example: the ids `550e8400-e29b-41d4-a716-446655440000`,\n`6ba7b810-9dad-11d1-80b4-00c04fd430c8` and\n`7c9e6679-7425-40de-944b-e07fc1f90ae7` give the example value.\nSent once. This is the only query parameter of the route: a\nvalue that is not 64 lower-case hex characters, the parameter\ntwice, or any other query key (a misspelt or encoded guard\nincluded) returns 400 `invalid_expected_accounts` before any SCA\nchallenge. A malformed path id stays 400 `invalid_id`.\n",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "example": "d3242a540a4af324a638f63b459fa5ce9d268a44ebe9f3d9cc805d69c2b7d77e"
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deleted": {
                      "type": "boolean",
                      "enum": [true]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BeneficiaryBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/BeneficiaryForbidden"
          },
          "404": {
            "$ref": "#/components/responses/BeneficiaryNotFound"
          },
          "409": {
            "$ref": "#/components/responses/PayeeChanged"
          },
          "414": {
            "description": "The request target (path and query) is longer than 2048 bytes (see Errors). `{\"error\":\"uri_too_long\"}`"
          }
        }
      }
    },
    "/api/v1/payees/{payeeId}/accounts": {
      "post": {
        "operationId": "addPayeeAccount",
        "tags": ["Payees"],
        "summary": "Add an account to a payee",
        "description": "Creates a row linked to the payee (`contact_id`) with the payee's\nparty fields copied from the root. Only account fields are read.\nThe account becomes the default when its currency has none. A\nmissing `currency` takes the root account's currency. Duplicates are\nchecked across all rows of the customer. On a `sanctions_flagged` payee the new\naccount is `sanctions_flagged` too.\nCustomer JWT: role `owner`, `admin` or `customer` (else 403\n`forbidden_role`); impersonation returns 403 `read_only_session`;\nanother customer's payee returns 404 `not_found`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "payeeId",
            "in": "path",
            "required": true,
            "description": "Payee id (the root account row). A malformed value returns 400 `invalid_id`.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PayeeAccountRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Account added; the whole payee is returned",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Payee"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BeneficiaryBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/BeneficiaryForbidden"
          },
          "404": {
            "$ref": "#/components/responses/BeneficiaryNotFound"
          },
          "409": {
            "$ref": "#/components/responses/BeneficiaryDuplicate"
          }
        }
      }
    },
    "/api/v1/payees/{payeeId}/accounts/{accountId}": {
      "put": {
        "operationId": "updatePayeeAccount",
        "tags": ["Payees"],
        "summary": "Edit one account",
        "description": "Only account fields are read; omitted fields keep their value. A\n`scheme` must come with that scheme's fields, and fields the scheme\ndoes not use are cleared (e.g. switching to `uk_account` drops the\nIBAN). Without `scheme`, on an account with a stored scheme, a\nfield that scheme does not use returns 400 `invalid_scheme`. Changing IBAN, BIC,\naccount or routing number resets verification as in\n`PUT /api/v1/beneficiaries/{id}`. Moving the default account to\nanother currency hands the default to the oldest remaining account\nof the old currency.\nCustomer JWT: role `owner`, `admin` or `customer` (else 403\n`forbidden_role`); impersonation returns 403 `read_only_session`;\nanother customer's payee returns 404 `not_found`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "payeeId",
            "in": "path",
            "required": true,
            "description": "Payee id (the root account row). A malformed value returns 400 `invalid_id`.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "accountId",
            "in": "path",
            "required": true,
            "description": "Account row id of this payee. A malformed value returns 400 `invalid_id`.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PayeeAccountRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Account updated; the whole payee is returned",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Payee"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BeneficiaryBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/BeneficiaryForbidden"
          },
          "404": {
            "$ref": "#/components/responses/BeneficiaryNotFound"
          },
          "409": {
            "$ref": "#/components/responses/BeneficiaryDuplicate"
          }
        }
      },
      "delete": {
        "operationId": "removePayeeAccount",
        "tags": ["Payees"],
        "summary": "Remove one account",
        "description": "The payee's last account is refused with 409 `last_account` (delete\nthe payee instead). Removing the root account promotes the oldest\nlinked account to root: it takes the party fields and the payee id\nbecomes its id; the other rows point at it. Row ids never change, so\ntransfer links (`beneficiary_id`) stay valid.\nIf the promoted account had another name or country, its\nverification restarts (`pending`, or `sanctions_flagged` when the\nold root was flagged) with an event, and it is re-screened.\nCustomer JWT: role `owner`, `admin` or `customer` (else 403\n`forbidden_role`); impersonation returns 403 `read_only_session`;\nanother customer's payee returns 404 `not_found`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "payeeId",
            "in": "path",
            "required": true,
            "description": "Payee id (the root account row). A malformed value returns 400 `invalid_id`.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "accountId",
            "in": "path",
            "required": true,
            "description": "Account row id of this payee. A malformed value returns 400 `invalid_id`.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deleted": {
                      "type": "boolean",
                      "enum": [true]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BeneficiaryBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/BeneficiaryForbidden"
          },
          "404": {
            "$ref": "#/components/responses/BeneficiaryNotFound"
          },
          "409": {
            "$ref": "#/components/responses/PayeeLastAccount"
          }
        }
      }
    },
    "/api/v1/payees/{payeeId}/accounts/{accountId}/default": {
      "post": {
        "operationId": "setPayeeDefaultAccount",
        "tags": ["Payees"],
        "summary": "Make an account the default for its currency",
        "description": "Exactly one account per payee and currency is the default.\nCustomer JWT: role `owner`, `admin` or `customer` (else 403\n`forbidden_role`); impersonation returns 403 `read_only_session`;\nanother customer's payee returns 404 `not_found`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "payeeId",
            "in": "path",
            "required": true,
            "description": "Payee id (the root account row). A malformed value returns 400 `invalid_id`.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "accountId",
            "in": "path",
            "required": true,
            "description": "Account row id of this payee. A malformed value returns 400 `invalid_id`.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Default changed; the whole payee is returned",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Payee"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BeneficiaryBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/BeneficiaryForbidden"
          },
          "404": {
            "$ref": "#/components/responses/BeneficiaryNotFound"
          }
        }
      }
    },
    "/api/v1/kam/assignments": {
      "get": {
        "operationId": "listKamAssignments",
        "tags": ["KAM"],
        "summary": "List KAM-to-customer assignments",
        "description": "Returns KAM assignments filtered by `kam_user_id` (all customers\nassigned to a specific KAM) or `tenant_id` (all assignments within\na tenant). At least one filter parameter is required.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "kam_user_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Filter by KAM user ID"
          },
          {
            "name": "tenant_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Filter by tenant"
          }
        ],
        "responses": {
          "200": {
            "description": "KAM assignment list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "assignments": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/KamAssignment"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          }
        }
      },
      "post": {
        "operationId": "createKamAssignment",
        "tags": ["KAM"],
        "summary": "Assign a KAM to a customer",
        "description": "Creates a new KAM-to-customer assignment. A customer may only have\none active KAM at a time per tenant. `assigned_by` records the admin\nwho created the assignment for audit purposes: for an admin session\nthe session's officer (DEC-0043; the body field is ignored), for a\nservice call the body field. Only `bank_admin` and the platform\n`super_admin` assign or remove (403 `forbidden_role` otherwise).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["kam_user_id", "customer_id", "tenant_id"],
                "properties": {
                  "kam_user_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "customer_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "tenant_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "assigned_by": {
                    "type": "string",
                    "description": "Service calls only (required there): the assigning admin. Ignored for an admin session"
                  },
                  "notes": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Assignment created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KamAssignment"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          }
        }
      }
    },
    "/api/v1/kam/assignments/{kamUserId}/{customerId}": {
      "delete": {
        "operationId": "deleteKamAssignment",
        "tags": ["KAM"],
        "summary": "Remove KAM assignment",
        "description": "Unassigns the specified KAM from the customer. The customer will\nhave no active KAM until a new assignment is created.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "kamUserId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Assignment deleted"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          }
        }
      }
    },
    "/api/v1/kam/candidates": {
      "get": {
        "operationId": "listKamCandidates",
        "tags": ["KAM"],
        "summary": "The bank's key account managers",
        "description": "The staff a customer can be assigned to (Core-Bank picks the KAM\nfrom this list by name, never by a typed id): active users with an\nactive `key_account_manager` membership in the cell of the request's\nbank (the session's in a cell, `X-Tenant-ID` in the platform scope;\n400 `tenant_required` without one). Another bank's staff are never\nlisted.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TenantScope"
          }
        ],
        "responses": {
          "200": {
            "description": "The key account managers, by name",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "candidates": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "email": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string",
                            "nullable": true
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "No bank named (`tenant_required`)"
          }
        }
      }
    },
    "/api/v1/kam/customer/{customerId}": {
      "get": {
        "operationId": "getKamForCustomer",
        "tags": ["KAM"],
        "summary": "Get the KAM assigned to a customer",
        "description": "Returns the active KAM assignment for the given customer.\nReturns `{\"assignment\": null}` (HTTP 200) if no KAM is assigned.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "KAM assignment or null",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "assignment": {
                      "nullable": true,
                      "$ref": "#/components/schemas/KamAssignment"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/kam/check": {
      "get": {
        "operationId": "checkKamAssignment",
        "tags": ["KAM"],
        "summary": "Check if a KAM is assigned to a customer (scoping check)",
        "description": "Returns `{\"assigned\": true|false}`. Used by the portal to determine\nwhether a KAM can access a customer's data (KAM scoping enforcement).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "kam_user_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "customer_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Assignment check result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "assigned": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/staff/names": {
      "get": {
        "operationId": "listStaffNames",
        "tags": ["Auth"],
        "summary": "Names and roles of the staff a screen mentions",
        "description": "Core-Bank shows who asked, decided, froze or closed something by\nname and role, never as a bare id (UX review X2). `refs` lists up\nto 100 operator ids, setup actor references (`staff:<id>`) or\ne-mail addresses, comma separated; other values are skipped.\n\nThe answer names the operators with a membership (current or\nrevoked) in the cell of the request's tenant, with their role in\nthat cell, and platform operators (`role` `super_admin`,\n`platform` true). Another bank's staff and unknown refs are left\nout. The tenant is the session's inside a cell; the platform scope\nnames it in `X-Tenant-ID`. Every cell role and the platform read\nit; support roles and customers do not.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "refs",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 8000
            },
            "description": "Comma-separated ids, `staff:<id>` references or e-mails (at most 100)."
          }
        ],
        "responses": {
          "200": {
            "description": "The staff the bank may name",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "staff": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "email": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string",
                            "nullable": true
                          },
                          "role": {
                            "type": "string",
                            "description": "The membership policy in the cell, or super_admin"
                          },
                          "platform": {
                            "type": "boolean",
                            "description": "A platform operator, not the bank's staff"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "No tenant named (`tenant_required`) or more than 100 refs (`too_many_refs`)"
          },
          "403": {
            "description": "A support role, a desk session or a customer"
          }
        }
      }
    },
    "/api/v1/ops-approvals": {
      "get": {
        "operationId": "listOpsApprovals",
        "tags": ["Approvals"],
        "summary": "Four-eyes requests on account actions (migration 268)",
        "description": "Requests for a second officer on a staff unfreeze, close or write-off\nof a customer account (wallet) or a ledger account, newest first\n(`order=asc`: oldest first), a page of `limit` (default 50, at most\n200) from `offset`; `total` counts every match. `counts` are the\nbank's pending requests whatever the filters, and those the caller\nmay decide (the Ops queue and the list say the same numbers). `can`\nsays what the caller may do: approve or reject (an\nactive `bank_admin` or `mlro` of the bank's cell in a cell session,\nnever the requester, never the platform scope), withdraw (the\nrequester). `approver_available` is false when no other officer of\nthe cell could decide. Staff of the bank; customers 403.\n\nWho is gated: a staff session, and a service call that acts for an\noperator (X-Acting-User-ID). A service key that names nobody is not\ngated and runs the unfreeze, close or write-off at once (workflows);\nthe staff route gate must not admit person-driven callers that way.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "status",
            "schema": {
              "type": "string",
              "enum": ["pending", "approved", "rejected", "withdrawn"]
            }
          },
          {
            "in": "query",
            "name": "subject_id",
            "description": "A wallet UUID or a ledger account id (hex).",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "search",
            "description": "Free text (case-insensitive, percent-encoded) over the account (name, IBAN, id), its customer, the reason and the people's e-mails.",
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          },
          {
            "in": "query",
            "name": "from",
            "description": "Requested on or after this day (UTC).",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "in": "query",
            "name": "to",
            "description": "Requested on or before this day (UTC).",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "in": "query",
            "name": "order",
            "schema": {
              "type": "string",
              "enum": ["asc", "desc"],
              "default": "desc"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "in": "query",
            "name": "offset",
            "description": "Above 1,000,000 is 400.",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 1000000,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The bank's requests",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "approvals": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/OpsApproval"
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "counts": {
                      "type": "object",
                      "properties": {
                        "pending": {
                          "type": "integer"
                        },
                        "decidable": {
                          "type": "integer",
                          "description": "Pending requests the caller may approve or reject."
                        },
                        "oldest_pending_at": {
                          "type": ["string", "null"],
                          "format": "date-time"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "An unknown status, a malformed subject, day or search, or an offset above 1,000,000."
          }
        }
      }
    },
    "/api/v1/ops-approvals/{approvalId}/approve": {
      "post": {
        "operationId": "approveOpsApproval",
        "tags": ["Approvals"],
        "summary": "A second officer approves; the action runs in the requester's name",
        "description": "Runs the unfreeze, close or write-off with the requester as actor and\ntheir reason, then records the approval (audit 2402 names both\npeople), all or nothing. The subject must be as the requester saw it\n(otherwise 409 `approval_stale`, the request stays pending); what\nthe action refuses now (`balance_not_zero`, `pending_transfers`,\n`compliance_hold`) leaves it pending too: reject it. A staff session\nis required (403 `session_required` for a service key).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "approvalId",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string",
                    "maxLength": 1000,
                    "description": "Optional note of the second officer."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Approved; `result` is the action's reply",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "approval": {
                      "$ref": "#/components/schemas/OpsApproval"
                    },
                    "result": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`four_eyes_required` (the requester, the platform scope, another role or bank), `session_required`, `person_required`"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`approval_not_pending`, `approval_stale`, `compliance_hold`, `already_closed`, `not_frozen`, `invalid_status`"
          },
          "422": {
            "description": "`balance_not_zero`, `pending_transfers`, `primary_account`"
          }
        }
      }
    },
    "/api/v1/ops-approvals/{approvalId}/reject": {
      "post": {
        "operationId": "rejectOpsApproval",
        "tags": ["Approvals"],
        "summary": "A second officer rejects (reason required); the requester withdraws",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "approvalId",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 10,
                    "maxLength": 1000,
                    "description": "Required for a rejection (at least 10 characters); optional for a withdrawal."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Rejected or withdrawn; nothing changed on the account",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "approval": {
                      "$ref": "#/components/schemas/OpsApproval"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`reason_required`"
          },
          "403": {
            "description": "`four_eyes_required`, `session_required`, `person_required`"
          },
          "409": {
            "description": "`approval_not_pending`"
          }
        }
      }
    },
    "/api/v1/ops-queue": {
      "get": {
        "operationId": "getOpsQueue",
        "tags": ["Approvals"],
        "summary": "The Ops desk's queue of the bank (read-only)",
        "description": "What waits on the Ops desk, in one read, each with a count and the\noldest item's time: transfers over a limit (they expire 72 hours\nafter they were made), approved transfers whose hand-off failed,\napproved transfers the booking refused and the desk has not yet\nacknowledged, of any age (`stopped_approvals`, by reason: no payee\naccount, an account blocked since the approval, a screening hold;\nnothing left the bank; POST /approvals/{approvalId}/acknowledge),\naccount changes for a second officer (`decidable`: those the caller\nmay decide; null for a role that does not read GET /ops-approvals),\ncash deposits waiting, approved cash deposits never credited,\nunassigned bookings, customers pending, and closures (in notice,\nand ready to close for good). The bank is the cell session's,\nX-Tenant-ID in the platform scope. Customers 403.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The queue",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "transfer_approvals": {
                      "type": "object",
                      "properties": {
                        "count": {
                          "type": "integer"
                        },
                        "oldest_at": {
                          "type": ["string", "null"],
                          "format": "date-time"
                        },
                        "expiring_within_24h": {
                          "type": "integer"
                        }
                      }
                    },
                    "handoff_failed": {
                      "$ref": "#/components/schemas/OpsQueueRow"
                    },
                    "stopped_approvals": {
                      "type": "object",
                      "description": "Approved transfers the booking refused (status failed) and not yet acknowledged, any age; nothing left the bank.",
                      "properties": {
                        "count": {
                          "type": "integer"
                        },
                        "oldest_at": {
                          "type": ["string", "null"],
                          "format": "date-time"
                        },
                        "payee_missing": {
                          "type": "integer"
                        },
                        "account_blocked": {
                          "type": "integer"
                        },
                        "screening_hit": {
                          "type": "integer"
                        },
                        "screening_unavailable": {
                          "type": "integer"
                        }
                      }
                    },
                    "account_changes": {
                      "type": ["object", "null"],
                      "properties": {
                        "count": {
                          "type": "integer"
                        },
                        "decidable": {
                          "type": "integer"
                        },
                        "oldest_at": {
                          "type": ["string", "null"],
                          "format": "date-time"
                        }
                      }
                    },
                    "cash_deposits": {
                      "$ref": "#/components/schemas/OpsQueueRow"
                    },
                    "credit_missing": {
                      "$ref": "#/components/schemas/OpsQueueRow"
                    },
                    "unassigned_bookings": {
                      "$ref": "#/components/schemas/OpsQueueRow"
                    },
                    "customers_pending": {
                      "$ref": "#/components/schemas/OpsQueueRow"
                    },
                    "closures": {
                      "type": "object",
                      "properties": {
                        "in_notice": {
                          "type": "integer"
                        },
                        "ready": {
                          "type": "integer",
                          "description": "Notice ended, or a closure for cause; \"Close for good\" is allowed."
                        },
                        "oldest_ready_at": {
                          "type": ["string", "null"],
                          "format": "date-time"
                        },
                        "next_deadline_at": {
                          "type": ["string", "null"],
                          "format": "date-time"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "No bank (`tenant_id is required`)"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/api/v1/desk-home/compliance": {
      "get": {
        "operationId": "getComplianceDeskHome",
        "tags": ["Compliance"],
        "summary": "The Compliance desk home's counts of the bank (read-only)",
        "description": "What waits on the Compliance desk, in one read, each with the oldest\nitem's time: open cases (all, unassigned, past their review\ndeadline, the next deadline, and the caller's own by the session's\nemail), four-eyes requests waiting for a second officer\n(`decidable`: those the caller may decide), drafts to lock, locked\nreports whose filing is not recorded and those past their reporting\ndeadline, open CDD reviews (`periodic`: from the review calendar;\n`overdue`: past their policy's hours), customers whose KYC is in\nreview, open list hits of ongoing screening, and enhanced due\ndiligence reviews not decided yet (`edd`: open and\n`awaiting_decision`, waiting for a second officer). `cases` and\n`second_officer` are null for a role that does not read\nGET /compliance-cases, `sars` for a role that does not read\nGET /sars, `edd` for a role that does not read GET /edd-reviews.\nThe bank is the cell session's, X-Tenant-ID in the platform scope.\nCustomers 403.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The counts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "cases": {
                      "type": ["object", "null"],
                      "properties": {
                        "open": {
                          "type": "integer"
                        },
                        "oldest_at": {
                          "type": ["string", "null"],
                          "format": "date-time"
                        },
                        "unassigned": {
                          "type": "integer"
                        },
                        "overdue": {
                          "type": "integer"
                        },
                        "next_due_at": {
                          "type": ["string", "null"],
                          "format": "date-time"
                        },
                        "mine": {
                          "type": "integer"
                        },
                        "mine_oldest_at": {
                          "type": ["string", "null"],
                          "format": "date-time"
                        },
                        "mine_overdue": {
                          "type": "integer"
                        }
                      }
                    },
                    "second_officer": {
                      "type": ["object", "null"],
                      "properties": {
                        "count": {
                          "type": "integer"
                        },
                        "oldest_at": {
                          "type": ["string", "null"],
                          "format": "date-time"
                        },
                        "decidable": {
                          "type": "integer"
                        }
                      }
                    },
                    "sars": {
                      "type": ["object", "null"],
                      "properties": {
                        "to_lock": {
                          "type": "integer"
                        },
                        "oldest_draft_at": {
                          "type": ["string", "null"],
                          "format": "date-time"
                        },
                        "to_record": {
                          "type": "integer"
                        },
                        "oldest_locked_at": {
                          "type": ["string", "null"],
                          "format": "date-time"
                        },
                        "overdue": {
                          "type": "integer"
                        }
                      }
                    },
                    "cdd_reviews": {
                      "type": "object",
                      "properties": {
                        "count": {
                          "type": "integer"
                        },
                        "oldest_at": {
                          "type": ["string", "null"],
                          "format": "date-time"
                        },
                        "periodic": {
                          "type": "integer"
                        },
                        "overdue": {
                          "type": "integer"
                        }
                      }
                    },
                    "kyc_waiting": {
                      "$ref": "#/components/schemas/OpsQueueRow"
                    },
                    "list_hits": {
                      "$ref": "#/components/schemas/OpsQueueRow"
                    },
                    "edd": {
                      "type": ["object", "null"],
                      "properties": {
                        "count": {
                          "type": "integer"
                        },
                        "oldest_at": {
                          "type": ["string", "null"],
                          "format": "date-time"
                        },
                        "awaiting_decision": {
                          "type": "integer"
                        },
                        "oldest_awaiting_at": {
                          "type": ["string", "null"],
                          "format": "date-time"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "No bank (`tenant_id is required`)"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/api/v1/desk-home/monitoring": {
      "get": {
        "operationId": "getMonitoringDeskHome",
        "tags": ["Observability"],
        "summary": "The Monitoring desk home's counts of the bank (read-only)",
        "description": "How the Monitoring desk's sources stand, in one read: outgoing\nnotifications delivered and failed in the last 24 hours, failed and\nwaiting now (with the oldest), and the staff access log of the last\n24 hours (entries, staff, refused and failed attempts, the last\nrefusal). `staff_access` is null for a role that does not read\nGET /officer-activity. The bank is the cell session's, X-Tenant-ID\nin the platform scope. Customers 403.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The counts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "notifications": {
                      "type": "object",
                      "properties": {
                        "delivered_24h": {
                          "type": "integer"
                        },
                        "failed_24h": {
                          "type": "integer"
                        },
                        "failed": {
                          "type": "integer"
                        },
                        "oldest_failed_at": {
                          "type": ["string", "null"],
                          "format": "date-time"
                        },
                        "waiting": {
                          "type": "integer"
                        },
                        "oldest_waiting_at": {
                          "type": ["string", "null"],
                          "format": "date-time"
                        }
                      }
                    },
                    "staff_access": {
                      "type": ["object", "null"],
                      "properties": {
                        "entries_24h": {
                          "type": "integer"
                        },
                        "staff_24h": {
                          "type": "integer"
                        },
                        "refused_24h": {
                          "type": "integer"
                        },
                        "failed_24h": {
                          "type": "integer"
                        },
                        "last_refused_at": {
                          "type": ["string", "null"],
                          "format": "date-time"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "No bank (`tenant_id is required`)"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/api/v1/approvals": {
      "get": {
        "operationId": "listApprovals",
        "tags": ["Approvals"],
        "summary": "List transfer approval requests",
        "description": "Returns transfer requests that exceeded configured limits and require\nmanual review by a second officer. Every filter runs over all rows of\nthe bank (cell staff: the session's; platform scope: `tenant_id` or\nX-Tenant-ID); `total` counts all matches, not the page.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "pending_review",
                "approved",
                "rejected",
                "expired",
                "failed"
              ]
            }
          },
          {
            "name": "tenant_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Free text (case-insensitive, percent-encoded) over id, debit and credit account (id, name, IBAN), description, limit reason, the customer (id, name, e-mail) and the payee (name, IBAN; spaces in an IBAN are ignored).",
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          },
          {
            "name": "sort",
            "in": "query",
            "description": "Sort column; ties by creation time. An unknown column is 400.",
            "schema": {
              "type": "string",
              "enum": ["created", "amount", "customer", "status"],
              "default": "created"
            }
          },
          {
            "name": "order",
            "in": "query",
            "description": "`asc`: oldest (smallest, A to Z) first; otherwise newest first.",
            "schema": {
              "type": "string",
              "enum": ["asc", "desc"],
              "default": "desc"
            }
          },
          {
            "name": "dispatch_failed",
            "in": "query",
            "description": "`true`: approved, unexecuted transfers whose hand-off failed (`redispatchable`: recorded as failed, dispatched but not executed 15 minutes later, or no hand-off recorded 15 minutes after the approval) and approvals from before 268 that were never executed (`expired_legacy`, not re-sendable).",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 100
            }
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Above 1,000,000 is 400.",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 1000000,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Approval request list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "approvals": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ApprovalRequest"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/approvals/stats": {
      "get": {
        "operationId": "getApprovalStats",
        "tags": ["Approvals"],
        "summary": "Get approval request counts by status",
        "description": "Returns aggregate counts of approval requests grouped by status, for\none bank: the session's (cell staff), else `tenant_id` or X-Tenant-ID\n(platform scope), else every bank. Used for the approvals queue.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tenant_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Approval statistics",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "pending": {
                      "type": "integer"
                    },
                    "approved": {
                      "type": "integer"
                    },
                    "rejected": {
                      "type": "integer"
                    },
                    "expired": {
                      "type": "integer"
                    },
                    "failed": {
                      "type": "integer"
                    },
                    "dispatch_failed": {
                      "type": "integer",
                      "description": "Approved, unexecuted transfers whose hand-off failed and may be sent again (as `redispatchable`); POST /approvals/{id}/dispatch."
                    },
                    "expired_legacy": {
                      "type": "integer",
                      "description": "Approved before migration 268 and never executed; never sent again, the customer submits again."
                    },
                    "oldest_pending_at": {
                      "type": ["string", "null"],
                      "format": "date-time",
                      "description": "When the oldest transfer still waiting was made (it expires 72 hours later)."
                    },
                    "expiring_within_24h": {
                      "type": "integer",
                      "description": "Transfers waiting that expire within a day (made more than 48 hours ago)."
                    },
                    "oldest_dispatch_failed_at": {
                      "type": ["string", "null"],
                      "format": "date-time",
                      "description": "The oldest failed hand-off's approval time."
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/approvals/customer/{customerId}": {
      "get": {
        "operationId": "listApprovalsByCustomer",
        "tags": ["Approvals"],
        "summary": "List approval requests for a specific customer",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Customer approval list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "approvals": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ApprovalRequest"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/approvals/{approvalId}": {
      "get": {
        "operationId": "getApproval",
        "tags": ["Approvals"],
        "summary": "Get approval request by ID",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "approvalId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Approval request details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApprovalRequest"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/approvals/{approvalId}/approve": {
      "post": {
        "operationId": "approveTransfer",
        "tags": ["Approvals"],
        "summary": "Approve a pending transfer request (second officer)",
        "description": "Second-officer approval for a transfer request that exceeded the\nconfigured limit threshold. The reviewer is the staff session's user\n(a `bank_admin` of the cell or the platform scope); a service key is\n403 `session_required`. A staff member never approves a transfer they\nmade (`requested_by`, migration 268): 403 `four_eyes_required`, the\nrequest stays pending. On approval the transfer is handed to the\nworkflow engine for durable ledger execution and the answer says\nwhether that hand-off worked (`dispatch`: `dispatched` or `failed`).\nA failed hand-off is recorded on the approval (`dispatch_status`\n`dispatch_failed`, audit 2404) and sent again with\nPOST /approvals/{approvalId}/dispatch. The ledger transfer itself runs\nasynchronously.\nA payment to another bank whose approval names no destination\naccount (an approval from before migration 293) is never approved:\n400 `{\"error\":\"payee_required\"}`, the request stays pending (reject\nit; the customer submits again).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "approvalId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "note": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Transfer approved; `dispatch` says whether the executor has it",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "status": {
                      "type": "string",
                      "enum": ["approved"]
                    },
                    "dispatch": {
                      "type": "string",
                      "enum": ["dispatched", "failed"]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "403": {
            "description": "`session_required`, `forbidden`, `four_eyes_required` (the reviewer made the transfer)"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/approvals/{approvalId}/acknowledge": {
      "post": {
        "operationId": "acknowledgeFailedApproval",
        "tags": ["Approvals"],
        "summary": "Acknowledge an approved transfer the booking refused (Ops desk)",
        "description": "For an approval with status `failed` (the booking refused it:\n`payee_missing`, `account_blocked`, `screening_hit`, ...; nothing\nleft the bank) that the bank's Ops desk has handled. It leaves the\nOps queue (`stopped_approvals`). A `bank_admin` or `mlro` session\ninside the bank's cell only: the platform scope is 403 `bank_only`\n(it reads, the bank handles its payments), a service key 403\n`session_required`, another role 403 `forbidden`. The reason (10 to\n1000 characters) and the staff member are stored on the approval\n(`acknowledged_at`, `acknowledged_by`, `acknowledged_reason`,\nmigration 301) and audited (2406). 409 `approval_not_failed`: not\nfailed, already acknowledged, or not an approval of the bank.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "approvalId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["reason"],
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 10,
                    "maxLength": 1000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Acknowledged",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "acknowledged": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`reason_required` (fewer than 10 characters)"
          },
          "403": {
            "description": "`session_required`, `bank_only`, `forbidden`"
          },
          "409": {
            "description": "`approval_not_failed`"
          }
        }
      }
    },
    "/api/v1/approvals/{approvalId}/dispatch": {
      "post": {
        "operationId": "redispatchApprovedTransfer",
        "tags": ["Approvals"],
        "summary": "Send an approved transfer to the executor again (failed hand-off)",
        "description": "For an approved, not yet executed transfer whose hand-off failed\n(`redispatchable`, migration 268). A ledger id derived from the\napproval already posted is sent to the executor as usual: it finds\nand links it and runs the once-only side effects. Only a legacy,\nnon-derived posting whose reference, tenant, debit and credit\naccount and amount all match the approval is linked here, recorded\nas linked without execution (audit 2405), and the answer is 409\n`already_executed`. The execution is idempotent per approval\n(ledger ids derived from it), so sending again never pays twice. An\n`expired_legacy` approval is never sent again (404). Staff session\nof a reviewer, as approve.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "approvalId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sent again; `dispatch` says whether the executor has it now",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "dispatch": {
                      "type": "string",
                      "enum": ["dispatched", "failed"]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`session_required`, `forbidden`"
          },
          "404": {
            "description": "Not an approved, unexecuted transfer with a failed hand-off"
          },
          "409": {
            "description": "`already_executed`: posted before; linked now"
          }
        }
      }
    },
    "/api/v1/approvals/{approvalId}/reject": {
      "post": {
        "operationId": "rejectTransfer",
        "tags": ["Approvals"],
        "summary": "Reject a pending transfer request",
        "description": "The reviewer is the staff session's user (as approve). The reason is\nstored and may be sent to the customer: at least 10 characters, and\nit must never mention a suspicion or a report (tipping-off). Emits\nthe `transfer_failed` webhook (not `transfer_completed`).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "approvalId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["reason"],
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 10,
                    "maxLength": 1000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Transfer rejected"
          },
          "400": {
            "description": "`reason_required` (at least 10 characters)"
          },
          "403": {
            "description": "`session_required`, `forbidden`"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/approvals/{approvalId}/execute-transfer": {
      "post": {
        "operationId": "executeApprovalTransfer",
        "tags": ["Approvals"],
        "summary": "Execute approved transfer in ledger engine (internal, workflow callback)",
        "description": "Internal callback invoked by the workflow engine (`X-Service-Key`, or\nthe internal callback secret in `X-Internal-Secret`); any other\ncaller gets 403. The approval must be `approved`. Accounts, amount,\nledger, code, currency and tenant come from the approval record; the\nbody may repeat them, and a different value is refused (409\n`body_mismatch`). The ledger transfer id is derived from the approval\nid, so a retry returns the same `transfer_id` with `replay: true`\ninstead of posting twice, and the id is linked to the approval once.\nThe fee and charge bearer stored at request time are posted as at\n`POST /api/v1/transfers` (DEC-0038, 0.31.0): `amount` + fee debited\n(a linked fee leg to the platform fee account), `amount` to the\ndestination; SWIFT `ben`: `amount` debited, `amount` - fee sent. The\ndebit is the `total_debit` the fee preview showed, also when the\nschedule changed since. An approval from before 0.31.0 has no stored\nfee and executes without one, as before. 503\n`fee_account_unavailable`: the fee account could not be read,\nnothing posted, retryable. An `expired_legacy` approval (approved\nbefore migration 268, never executed) with no posted transfer of its\nown is 409 `expired_legacy`: nothing is posted, the executor stops.\nA payment to another bank (the rail stored at request time,\nmigration 293; on an older approval its event type or a credit to\nthe platform master account) executes only with the destination\naccount (IBAN or account number) the request named, and its record\ncarries that payee (`destination_name`, `destination_iban`,\n`destination_bic`, `destination_account_number`, `rail`), which the\nhistory, the receipts and the MT103 / pacs.008 export read. Without\none (an approval from before 293) nothing is posted: the approval\nends `failed` with `failure_reason` `payee_missing` (never sent\nagain), 409 `payee_missing`, the executor stops. 503\n`payee_check_unavailable`: whether the money leaves the bank could\nnot be read, nothing posted, retryable.\nOne execution of an approval at a time: the checks, the post and the\nlink (or the refusal) run under a lock on the approval id (503\n`approval_busy` when it cannot be taken: retryable). Before it posts,\nthe execution runs AccountGuard again, and for a payment to another\nbank a live screen of the stored payee (its name and country, never\nthe saved payee's current record nor a fresh result of it;\n2026-10-07): an account frozen, closed or written off since the\nrequest posts nothing, the approval ends `failed` (`account_blocked`);\na screening hold opens its case (the saved payee's, else on the\npaying customer) and ends it `failed` (`screening_hit`); a bank that\nrequires screening (fail-closed) with a stored payee without a name\nends it `failed` (`screening_unavailable`). Each writes an audit row,\nanswers 409 with the reason, and the executor stops. 503\n`account_guard_unavailable`, `screening_retry_later` (screening could\nnot run where required) or `screening_case_unavailable` (a hold whose\ncase could not be opened): nothing posted, retryable. An internal\ntransfer meets the gate as a direct one. The record carries everything the request\nnamed (`reference`, `counterparty_name`, `beneficiary_id`, the SWIFT\nand bank fields, `sepa_end_to_end_id`, migration 301) and the\napproval in its own `approval_id` column (the re-send lookup reads\nit; `reference` stays the customer's). The rule book's shadow runs on\nit as on a direct payment.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "approvalId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "description": "Optional repetition of the approval; checked, never used.",
                "properties": {
                  "debit_account_id": {
                    "type": "string",
                    "description": "Hex-encoded ledger account ID"
                  },
                  "credit_account_id": {
                    "type": "string",
                    "description": "Hex-encoded ledger account ID"
                  },
                  "amount": {
                    "type": "integer",
                    "format": "int64"
                  },
                  "currency": {
                    "type": "string"
                  },
                  "ledger": {
                    "type": "integer"
                  },
                  "transfer_code": {
                    "type": "integer"
                  },
                  "description": {
                    "type": "string"
                  },
                  "workflow_id": {
                    "type": "string"
                  },
                  "correlation_id": {
                    "type": "string"
                  },
                  "tenant_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "fee_amount": {
                    "type": "integer",
                    "format": "int64"
                  },
                  "charge_bearer": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Transfer executed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "transfer_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "example": "executed"
                    },
                    "replay": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Not an internal caller, or `tenant_mismatch`"
          },
          "404": {
            "description": "Approval not found"
          },
          "409": {
            "description": "`not_approved`, `executed_elsewhere`, `body_mismatch`, `ledger_id_conflict`, `expired_legacy`, `payee_missing`, `account_blocked`, `screening_hit` or `screening_unavailable`"
          },
          "422": {
            "description": "`invalid_record`, `tenant_required` or deposit cap refusal"
          }
        }
      }
    },
    "/api/v1/approvals/{approvalId}/expire": {
      "post": {
        "operationId": "expireApproval",
        "tags": ["Approvals"],
        "summary": "Expire a pending approval (internal, delayed workflow invocation)",
        "description": "Auto-expiry callback called by delayed workflow invocation after the\nconfigured approval window. Marks the request as `expired` only if\nit is still in `pending_review` state (idempotent).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "approvalId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Approval expired or already resolved"
          }
        }
      }
    },
    "/api/v1/approvals/{approvalId}/dispatch-failed": {
      "post": {
        "operationId": "approvalExecutorFailed",
        "tags": ["Approvals"],
        "summary": "Record that the executor gave up on an approved transfer (internal)",
        "description": "Called by the TransferApprovalExecutor workflow when executing an\napproved transfer failed after its retries. The approval becomes\n`dispatch_failed` (audit 2404), shown on the approvals queue and\nsent again with POST /approvals/{approvalId}/dispatch. Service key or\nX-Internal-Secret only. 200 also when nothing applies (the approval\nis linked to its transfer or no longer approved).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "approvalId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string",
                    "maxLength": 200
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`{\"status\":\"dispatch_failed\"}` or `{\"status\":\"not_applicable\"}`"
          },
          "403": {
            "description": "Not an internal caller"
          }
        }
      }
    },
    "/api/v1/stats/overview": {
      "get": {
        "operationId": "getStatsOverview",
        "tags": ["Stats"],
        "summary": "Admin dashboard KPI overview",
        "description": "Returns aggregate KPI metrics for the admin dashboard: customer\ncounts by status (total, active, pending, suspended, new last 30 days),\ntransfer volume (today and this month), KYC session stats by status,\nand pending approval count. All values are computed via PostgreSQL\naggregate queries.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "KPI overview",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "customers": {
                      "type": "object",
                      "properties": {
                        "total": {
                          "type": "string"
                        },
                        "active": {
                          "type": "string"
                        },
                        "pending": {
                          "type": "string"
                        },
                        "suspended": {
                          "type": "string"
                        },
                        "new_30d": {
                          "type": "string"
                        }
                      }
                    },
                    "transfers": {
                      "type": "object",
                      "properties": {
                        "today_volume": {
                          "type": "string"
                        },
                        "today_count": {
                          "type": "string"
                        },
                        "month_volume": {
                          "type": "string"
                        },
                        "month_count": {
                          "type": "string"
                        },
                        "total_count": {
                          "type": "string"
                        }
                      }
                    },
                    "kyc": {
                      "type": "object",
                      "properties": {
                        "total": {
                          "type": "string"
                        },
                        "approved": {
                          "type": "string"
                        },
                        "rejected": {
                          "type": "string"
                        },
                        "in_review": {
                          "type": "string"
                        },
                        "pending": {
                          "type": "string"
                        }
                      }
                    },
                    "pending_approvals": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/stats/transfers": {
      "get": {
        "operationId": "getTransferStats",
        "tags": ["Stats"],
        "summary": "Transfer volume time series for charts",
        "description": "Returns time-series transfer volume data for the admin dashboard.\nDefault granularity: `daily` (last 30 days). Set `period=monthly`\nfor last 12 months. Optional `date_from` / `date_to` (YYYY-MM-DD)\noverride the default window. Only completed transfers are counted.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "period",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": ["daily", "monthly"],
              "default": "daily"
            }
          },
          {
            "name": "date_from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "date_to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Time-series transfer volume",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "period": {
                            "type": "string",
                            "description": "YYYY-MM-DD (daily) or YYYY-MM (monthly)"
                          },
                          "volume": {
                            "type": "string",
                            "description": "Aggregate transfer amount (minor units)"
                          },
                          "count": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/report-jobs": {
      "get": {
        "operationId": "listReportJobs",
        "tags": ["Reports"],
        "summary": "List report generation jobs",
        "description": "Returns the 50 most recent report generation jobs ordered by\ncreation date descending. Each job tracks the status of an\nasynchronous report generation request (queued, processing,\ncompleted, failed). A staff role that sees only its assigned\ncustomers (every role but super_admin, bank_admin, mlro and auditor)\nlists only the jobs it requested in such a role.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Report job list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "jobs": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ReportJob"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createReportJob",
        "tags": ["Reports"],
        "summary": "Create a report generation job",
        "description": "Creates a new async report generation job and optionally dispatches\nit to the report generation workflow. The job is immediately\ncreated in `queued` status; the workflow updates it to `processing`\nand then `completed` or `failed`.\n\nThe job belongs to the request's tenant (the session's inside a\ncell, `X-Tenant-ID` in the platform scope). A request without a\ntenant is refused (403 `tenant_required`): an export always covers\none bank. The job records its requester (`requested_by_user_id`,\n`requested_by_role`: the session's user and effective role, never a\nbody field); a service key acting for nobody is refused (403\n`staff_required`).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["requested_by"],
                "properties": {
                  "report_type": {
                    "type": "string",
                    "enum": [
                      "transaction_export",
                      "customer_export",
                      "audit_export"
                    ],
                    "default": "transaction_export"
                  },
                  "format": {
                    "type": "string",
                    "enum": ["csv"],
                    "default": "csv",
                    "description": "CSV only (the workflow writes CSV); anything else is 400 `invalid_format`"
                  },
                  "requested_by": {
                    "type": "string",
                    "description": "Admin user ID"
                  },
                  "filters_json": {
                    "type": "string",
                    "description": "JSON-encoded filter object (e.g. {\"date_from\":\"2025-01-01\"}). `date_from`/`date_to` are real calendar days (YYYY-MM-DD), from not after to (else 400 `invalid_date`); `customer_id` a UUID (else 400 `invalid_customer_scope`); string values only (else 400 `invalid_job_filters`)",
                    "example": "{\"date_from\":\"2025-01-01\",\"date_to\":\"2025-03-31\"}"
                  },
                  "workflow_id": {
                    "type": "string",
                    "description": "Workflow engine execution ID (optional)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Report job created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "status": {
                      "type": "string",
                      "example": "queued"
                    },
                    "created_at": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`{\"error\":\"invalid_format\"}`, `{\"error\":\"invalid_date\"}`, `{\"error\":\"invalid_customer_scope\"}` or `{\"error\":\"invalid_job_filters\"}`"
          },
          "403": {
            "description": "`{\"error\":\"tenant_required\"}`: the request has no tenant; `{\"error\":\"staff_required\"}`: no staff session (a service key acting for nobody)"
          }
        }
      }
    },
    "/api/v1/report-jobs/{jobId}": {
      "get": {
        "operationId": "getReportJob",
        "tags": ["Reports"],
        "summary": "Get report job status and metadata",
        "description": "A staff role that sees only its assigned customers reads only the\njobs it requested in such a role (a job it requested as bank_admin,\nbefore a role change, is not its any more); another job answers 404\nlike an unknown one.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "jobId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Report job details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReportJob"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "patch": {
        "operationId": "updateReportJob",
        "tags": ["Reports"],
        "summary": "Update report job status (internal, workflow callback)",
        "description": "Updates the status, S3 key, file size, and row count on a report job.\nCalled by the report generation workflow after processing (it posts:\n`POST /api/v1/report-jobs/{jobId}` updates like `PATCH`).\nSets `started_at` when transitioning to `processing`, and\n`completed_at` on `completed` or `failed`.\n\nThe service key only (`X-Service-Key` acting for nobody): the S3 key\ndecides which file the download streams, so a staff session (or a\nservice call acting for an operator) is refused with 403\n`service_only`. Only a `queued` or `processing` job moves: a finished\njob keeps its status, file key and counts (409 `job_finished`; the\nsame status again answers 200 and writes nothing, for a retried\ncall). An unknown status is 400 `invalid_status`.\n",
        "security": [
          {
            "ServiceKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "jobId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["status"],
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": ["queued", "processing", "completed", "failed"]
                  },
                  "s3_key": {
                    "type": "string",
                    "description": "S3 object key for the generated file"
                  },
                  "error_message": {
                    "type": "string"
                  },
                  "file_size_bytes": {
                    "type": "integer",
                    "format": "int64"
                  },
                  "row_count": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Job updated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "status": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`{\"error\":\"invalid_status\"}`: not queued, processing, completed or failed"
          },
          "403": {
            "description": "`{\"error\":\"service_only\"}`: the caller is not the service key"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`{\"error\":\"job_finished\"}`: the job is completed or failed already"
          }
        }
      }
    },
    "/api/v1/report-jobs/{jobId}/transfers": {
      "get": {
        "operationId": "exportReportJobTransfers",
        "tags": ["Reports"],
        "summary": "The transfers of a report job (internal, workflow)",
        "description": "The ReportGeneration workflow's export. The service key only, with\n`X-Tenant-ID`: the job must be that tenant's (else 404). Everything\nelse comes from the job row: its stored filters (`date_from`,\n`date_to`, `status`, `customer_id`) and, when its requester's role\nsees only assigned customers, those customers (`finance_kam_assignment`,\nnone without an assignment: an empty export). Nothing comes from the\nquery string. Answers like `GET /api/v1/transfers/export`.\n",
        "security": [
          {
            "ServiceKeyAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TenantScope"
          },
          {
            "name": "jobId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The job's transfers",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "transfers": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`{\"error\":\"service_only\"}`: not the service key; `{\"error\":\"tenant_required\"}`: no X-Tenant-ID"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "400": {
            "description": "`{\"error\":\"invalid_date\"}`: a stored date is not a real calendar day, or from is after to"
          },
          "422": {
            "description": "`{\"error\":\"job_requester_unknown\"}`: the job records no requester (created before migration 257; generate it again); `{\"error\":\"invalid_job_filters\"}` or `{\"error\":\"invalid_customer_scope\"}`: the stored filters are not usable"
          }
        }
      }
    },
    "/api/v1/invite/accept": {
      "post": {
        "operationId": "acceptInvite",
        "tags": ["Invitations"],
        "summary": "Accept a customer member invitation",
        "description": "Accepts a pending invitation to join a customer organization as a\nmember. The invitation token is validated and the user is added\nto the customer's member list with the role specified in the\ninvitation. This is a pre-auth endpoint (no Bearer token required);\nauthentication is via the invitation token in the request body.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["token"],
                "properties": {
                  "token": {
                    "type": "string",
                    "description": "Invitation token from email link"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Invitation accepted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "description": "Invitation not found or expired"
          }
        }
      }
    },
    "/api/v1/tb/accounts": {
      "get": {
        "operationId": "queryTbAccounts",
        "tags": ["LedgerReadOnlyInspection"],
        "summary": "Query ledger accounts with filter",
        "description": "Queries accounts from the ledger engine using the\n`query_accounts` operation. Supports filter parameters: `ledger`,\n`code`, `limit`, `user_data_128`, `user_data_64`, `user_data_32`,\n`timestamp_min`, `timestamp_max`, `reversed`. Read-only; no writes.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "ledger",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "Ledger ID (currency code, e.g. 978 for EUR)"
          },
          {
            "name": "code",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "Account type code"
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 100
            }
          },
          {
            "name": "user_data_128",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Decimal u128 filter"
          },
          {
            "name": "reversed",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Account list from the ledger engine",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "accounts": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/TbAccount"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tb/accounts/{id}": {
      "get": {
        "operationId": "lookupTbAccount",
        "tags": ["LedgerReadOnlyInspection"],
        "summary": "Lookup a single ledger account by decimal ID",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Account ID as decimal u128"
          }
        ],
        "responses": {
          "200": {
            "description": "Account details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TbAccount"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/tb/accounts/{id}/transfers": {
      "get": {
        "operationId": "getTbAccountTransfers",
        "tags": ["LedgerReadOnlyInspection"],
        "summary": "Get transfers for a ledger account",
        "description": "Returns debit and credit transfers for the given account. Supports\n`limit` (default 100, max 500) and `reversed` (newest first) query\nparameters.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Account ID as decimal u128"
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 100,
              "maximum": 500
            }
          },
          {
            "name": "reversed",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Transfer list for account",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "transfers": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/TbTransfer"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tb/accounts/{id}/balances": {
      "get": {
        "operationId": "getTbAccountBalances",
        "tags": ["LedgerReadOnlyInspection"],
        "summary": "Get historical balance snapshots for a ledger account",
        "description": "Returns periodic balance snapshots (credits_posted, debits_posted,\npending amounts) for the account. Supports `limit` (default 50)\nand `reversed` (newest first).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Account ID as decimal u128"
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 50
            }
          },
          {
            "name": "reversed",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Balance snapshots",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "account_id": {
                      "type": "string"
                    },
                    "balances": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/TbAccountBalance"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tb/transfers": {
      "get": {
        "operationId": "queryTbTransfers",
        "tags": ["LedgerReadOnlyInspection"],
        "summary": "Query ledger transfers with filter",
        "description": "Queries transfers from the ledger engine using the\n`query_transfers` operation. Supports the same filter parameters\nas the accounts query.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "ledger",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "code",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 100
            }
          },
          {
            "name": "reversed",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Transfer list from the ledger engine",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "transfers": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/TbTransfer"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tb/transfers/{id}": {
      "get": {
        "operationId": "lookupTbTransfer",
        "tags": ["LedgerReadOnlyInspection"],
        "summary": "Lookup a single ledger transfer by decimal ID",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Transfer ID as decimal u128"
          }
        ],
        "responses": {
          "200": {
            "description": "Transfer details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TbTransfer"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/rate-limit/config": {
      "get": {
        "operationId": "getRateLimitConfig",
        "tags": ["Health"],
        "summary": "Retrieve rate limit configuration",
        "description": "Returns the current rate limiting settings applied to API requests.\nDefault: 100 requests per 60-second window per source IP. Rate limits\nprotect against abuse and ensure fair resource allocation across tenants.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Rate limit settings (100 req/60s per IP)"
          }
        }
      }
    },
    "/api/v1/closure-policies": {
      "get": {
        "operationId": "listClosurePolicies",
        "tags": ["Customers"],
        "summary": "Account termination rules of the bank",
        "description": "The bank's closure policy versions (newest first), the platform\ndefault it falls back to, and the statutory floor of its\njurisdiction (`finance_jurisdiction_profile.closure_notice_floor_days`,\nmigration 267: 62 days in the EEA and UK, 0 in CH). The bank is the\nsession's (or `X-Tenant-ID` for a platform or service call).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Versions and floor",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "policies": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ClosurePolicy"
                      }
                    },
                    "floor_days": {
                      "type": "integer"
                    },
                    "jurisdiction": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`tenant_required`"
          }
        }
      },
      "post": {
        "operationId": "createClosurePolicy",
        "tags": ["Customers"],
        "summary": "New draft version",
        "description": "A draft for the bank; `notice_period_days` at least the statutory\nfloor (400 `notice_below_floor`), `aml_notice_period_days` at most\nthe ordinary notice. Drafts: bank_admin or mlro (an\nMLRO's draft changes the AML notice only; the rest comes from the\npolicy in force). Audited (`closure_policy.drafted`).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateClosurePolicyRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Draft created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClosurePolicy"
                }
              }
            }
          },
          "400": {
            "description": "`notice_below_floor`, `notice_invalid`, `aml_notice_invalid`, `framework_invalid`, `reason_categories_invalid`, `escalation_contacts_invalid`, `tenant_required`"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/api/v1/closure-policies/active": {
      "get": {
        "operationId": "getActiveClosurePolicy",
        "tags": ["Customers"],
        "summary": "The policy in force (the bank's, else the platform default)",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The policy, or null",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ClosurePolicy"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/closure-policies/floor": {
      "get": {
        "operationId": "getClosurePolicyFloor",
        "tags": ["Customers"],
        "summary": "The statutory minimum notice of the bank's jurisdiction",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Floor",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "floor_days": {
                      "type": "integer",
                      "example": 62
                    },
                    "jurisdiction": {
                      "type": "string",
                      "example": "ES"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/closure-policies/{policyId}/activate": {
      "post": {
        "operationId": "activateClosurePolicy",
        "tags": ["Customers"],
        "summary": "Activate a draft (the previous active version is archived)",
        "description": "One active version per bank. bank_admin (super_admin reads only, DEC-0042); audited (`closure_policy.activated`).",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "policyId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Activated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClosurePolicy"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`wrong_state`: not a draft of this bank"
          }
        }
      }
    },
    "/api/v1/closure-policies/{policyId}/archive": {
      "post": {
        "operationId": "archiveClosurePolicy",
        "tags": ["Customers"],
        "summary": "Archive a draft or the active version",
        "description": "bank_admin (super_admin reads only, DEC-0042); audited (`closure_policy.archived`). Versions are never edited or deleted.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "policyId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Archived",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClosurePolicy"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`wrong_state`"
          }
        }
      }
    },
    "/api/v1/closure-audit-records": {
      "post": {
        "operationId": "createClosureAuditRecord",
        "tags": ["Audit"],
        "summary": "Record an account-closure workflow step",
        "description": "Appends a discrete step of the account closure workflow to the audit\ntrail (BR-EF-028). Called as the closure workflow\nprogresses through each stage. Requires the X-Tenant-ID header.\n\nStaff (DEC-0043): the platform `super_admin` only (403\n`forbidden_role` otherwise). `actor_email` is the admin session's\nofficer; the body field is read only from a service call.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["customer_id", "step"],
                "properties": {
                  "customer_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "step": {
                    "type": "string",
                    "enum": [
                      "closure_initiated",
                      "notification_sent",
                      "wallet_closing",
                      "wallet_closed",
                      "account_closing",
                      "account_closed",
                      "customer_closed",
                      "closure_cancelled"
                    ]
                  },
                  "actor_email": {
                    "type": "string",
                    "description": "Service calls only. Ignored for an admin session (its officer is recorded)"
                  },
                  "entity_type": {
                    "type": "string"
                  },
                  "entity_id": {
                    "type": "string"
                  },
                  "metadata": {
                    "type": "object"
                  },
                  "template_snapshot": {
                    "type": "object"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Audit record created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "created_at": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          }
        }
      }
    },
    "/api/v1/kyc-screening-log": {
      "get": {
        "operationId": "listKycScreeningLog",
        "tags": ["Screening"],
        "summary": "List AML screening audit log entries",
        "description": "Returns AML screening operations recorded for the tenant (AML record\nkeeping), newest first. Optional filters by operation\nand subject name. Requires the X-Tenant-ID header.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "operation",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "search",
                "person_details",
                "add_monitoring",
                "remove_monitoring",
                "list_monitoring",
                "add_blacklist",
                "remove_blacklist",
                "list_blacklist"
              ]
            }
          },
          {
            "name": "subject",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Case-insensitive substring match on subject_name"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 25
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Screening log entries",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "entries": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/KycScreeningLogEntry"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      },
      "post": {
        "operationId": "createKycScreeningLog",
        "tags": ["Screening"],
        "summary": "Record an AML screening operation",
        "description": "Stores a screening operation in the audit log. Required: operation;\nperformed_by for a service call. Requires the X-Tenant-ID header.\n\nStaff (DEC-0043): `bank_admin`, `mlro` and the platform\n`super_admin` (403 `forbidden_role` otherwise). For an admin session\n`performed_by` and `performed_by_role` are the session's officer and\nrole; the body fields are read only from a service call.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["operation"],
                "properties": {
                  "operation": {
                    "type": "string",
                    "enum": [
                      "search",
                      "person_details",
                      "add_monitoring",
                      "remove_monitoring",
                      "list_monitoring",
                      "add_blacklist",
                      "remove_blacklist",
                      "list_blacklist"
                    ]
                  },
                  "performed_by": {
                    "type": "string",
                    "description": "Service calls only (required there). Ignored for an admin session"
                  },
                  "performed_by_role": {
                    "type": "string",
                    "description": "Service calls only. Ignored for an admin session"
                  },
                  "provider": {
                    "type": "string",
                    "default": "identomat"
                  },
                  "request_params": {
                    "type": "object"
                  },
                  "response_data": {
                    "type": "object"
                  },
                  "subject_name": {
                    "type": "string"
                  },
                  "customer_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "match_count": {
                    "type": "integer"
                  },
                  "highest_score": {
                    "type": "number"
                  },
                  "result_summary": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Log entry created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "created_at": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          }
        }
      }
    },
    "/api/v1/kyc-screening-log/{entryId}": {
      "get": {
        "operationId": "getKycScreeningLog",
        "tags": ["Screening"],
        "summary": "Get a screening log entry",
        "description": "Returns a single AML screening log entry including the full request and\nresponse payloads. Requires the X-Tenant-ID header.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "entryId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Screening log entry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KycScreeningLogEntry"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/monthly-statements": {
      "get": {
        "operationId": "listMonthlyStatements",
        "tags": ["Statements"],
        "summary": "List monthly account statements",
        "description": "Returns monthly statements for a customer (Documents area), newest first.\nRequired customer_id; optional wallet_id filter. Tenant-isolated via RLS.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "customer_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "wallet_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Statement list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "statements": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/MonthlyStatement"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      },
      "post": {
        "operationId": "createMonthlyStatement",
        "tags": ["Statements"],
        "summary": "Create a statement record (internal workflow use)",
        "description": "Creates one statement record per wallet per period. Called by the\nMonthlyStatementScheduler workflow via X-Service-Key authentication.\n",
        "security": [
          {
            "ServiceKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MonthlyStatement"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Statement record created"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/v1/monthly-statements/data": {
      "get": {
        "operationId": "getMonthlyStatementData",
        "tags": ["Statements"],
        "summary": "Fetch statement balances and transactions (internal workflow use)",
        "description": "Returns the balance summary and transaction list for a wallet/period,\nused by the MonthlyStatementGeneration workflow to render the document.\nService-key authenticated.\n",
        "security": [
          {
            "ServiceKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "wallet_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "currency",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "year",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "month",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Balance summary and transactions"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/v1/monthly-statements/pending-wallets": {
      "get": {
        "operationId": "getMonthlyStatementPendingWallets",
        "tags": ["Statements"],
        "summary": "List wallets without a statement for a period (internal workflow use)",
        "description": "Returns wallets that do not yet have a statement for the given period.\nCalled by the MonthlyStatementScheduler to determine generation targets.\nService-key authenticated.\n",
        "security": [
          {
            "ServiceKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "year",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "month",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Pending wallet list"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/v1/monthly-statements/{statementId}": {
      "get": {
        "operationId": "getMonthlyStatement",
        "tags": ["Statements"],
        "summary": "Get a monthly statement",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "statementId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Statement detail",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MonthlyStatement"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "patch": {
        "operationId": "updateMonthlyStatement",
        "tags": ["Statements"],
        "summary": "Update statement status and metadata (internal workflow use)",
        "description": "Commits the generated status, S3 key, file size, and computed balances.\nCalled by the MonthlyStatementGeneration workflow. Service-key authenticated.\n",
        "security": [
          {
            "ServiceKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "statementId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MonthlyStatement"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Statement updated"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/metrics": {
      "get": {
        "operationId": "getMetrics",
        "tags": ["Observability"],
        "summary": "Prometheus metrics",
        "description": "Returns atomic counters for finance-api operations in Prometheus text\nexposition format (text/plain; version=0.0.4). Counters include:\nfinance_api_requests_total, finance_api_errors_total,\nfinance_wallet_events_total, finance_kyc_outcomes_total,\nfinance_transfers_total, finance_screening_hits_total.\nNo authentication required \u2014 restrict access at the network/proxy layer.\n",
        "responses": {
          "200": {
            "description": "Prometheus text exposition format",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/compliance/rules": {
      "get": {
        "operationId": "listComplianceRules",
        "tags": ["ComplianceRules"],
        "summary": "List the officer-visible rule book",
        "description": "Tenant-scoped catalogue. Inventory rows are visible and MUST NOT evaluate.\nShadow rows log only. Money still settles. No freeze on this resource.\n`pending_change_id` names a change of the rule that waits for a second\nMLRO (migration 278).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "X-Tenant-ID",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Catalogue list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ComplianceRuleList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      },
      "post": {
        "operationId": "createComplianceRule",
        "tags": ["ComplianceRules"],
        "summary": "Ask a second MLRO to add a rule",
        "description": "Maker-checker (migration 278): nothing is added yet. The request is a\npending change with a `reason` (10 to 1000 characters); another\nactive `mlro` of the bank's cell approves it\n(`POST /compliance/rules/changes/{changeId}/approve`), which adds the\ninventory row (evaluator none). Title plus When/If/Then are required;\nthe typology slug is generated at approval. Hold is rejected. Cash\nWhen is rejected on CH. A staff session of a cell MLRO is required:\na service key acting for nobody is 403 `person_required`, any other\nrole (also super_admin, read-only on a bank's AML configuration) 403\n`mlro_required`. Audit `compliance.rule.change_requested` (700).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "X-Tenant-ID",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ComplianceRuleCreate"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "The pending change",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RuleChangeAnswer"
                }
              }
            }
          },
          "400": {
            "description": "Invalid rule, or `reason_required`"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "`forbidden_role` (staff route gate, DEC-0043), `person_required` or `mlro_required`"
          }
        }
      }
    },
    "/api/v1/compliance/rules/{ruleId}": {
      "patch": {
        "operationId": "patchComplianceRule",
        "tags": ["ComplianceRules"],
        "summary": "Ask a second MLRO to change a rule",
        "description": "Maker-checker (migration 278): the rule does not change yet. The\nrequest is a pending change with a `reason`; a second MLRO of the\ncell approves it, which applies it with both people and the reason on\nthe revision row and the TM projection follows (a row that stops\nprojecting disables its `finance_tm_rule` rows). Live or shadow\nwithout an engine stays inventory. Hold is rejected. A gate (kyc,\nscreening, cdd, cash) keeps its status, mode and engine: only its\ntexts change (400). One pending change per rule (409\n`change_pending`).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "X-Tenant-ID",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "ruleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ComplianceRulePatch"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "The pending change",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RuleChangeAnswer"
                }
              }
            }
          },
          "400": {
            "description": "Invalid patch, a live gate, or `reason_required`"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "`forbidden_role` (staff route gate, DEC-0043), `person_required` or `mlro_required`"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`change_pending`"
          }
        }
      },
      "delete": {
        "operationId": "deleteComplianceRule",
        "tags": ["ComplianceRules"],
        "summary": "Ask a second MLRO to retire a rule",
        "description": "Maker-checker (migration 278): a pending retire with a `reason` in the\nJSON body (never in the URL). On approval the rule is retired\n(status disabled, inventory; never deleted, DEC-0014) and its TM\nprojection is disabled. A gate is never retired (400).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "X-Tenant-ID",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "ruleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["reason"],
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 10,
                    "maxLength": 1000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "The pending change",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RuleChangeAnswer"
                }
              }
            }
          },
          "400": {
            "description": "A live gate, or `reason_required`"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "`person_required` or `mlro_required`"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`change_pending`"
          }
        }
      }
    },
    "/api/v1/compliance/rules/{ruleId}/revisions": {
      "get": {
        "operationId": "listComplianceRuleRevisions",
        "tags": ["ComplianceRules"],
        "summary": "Configuration history of a rule",
        "description": "Append-only (migration 278: UPDATE and DELETE are refused for every\nwriter). Each revision names the change request, its reason, the\nrequester and the second officer who approved it.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "X-Tenant-ID",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "ruleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Revisions, newest first (at most 50)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RuleRevisionList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          }
        }
      }
    },
    "/api/v1/compliance/rules/changes": {
      "get": {
        "operationId": "listComplianceRuleChanges",
        "tags": ["ComplianceRules"],
        "summary": "Rule changes waiting for a second MLRO",
        "description": "`status=pending` (default) or `all` (the last 100). `can` says what\nthe caller may do: approve or reject (another active `mlro` of the\nbank's cell), withdraw (the requester). `approver_available` is false\nwhen the bank has no second MLRO. `stale` marks a request whose rule\nchanged since.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "X-Tenant-ID",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["pending", "all"],
              "default": "pending"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Change list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RuleChangeList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/v1/compliance/rules/changes/{changeId}/approve": {
      "post": {
        "operationId": "approveComplianceRuleChange",
        "tags": ["ComplianceRules"],
        "summary": "Approve and apply a rule change (second MLRO)",
        "description": "Another active `mlro` of the bank's cell, never the requester (403\n`four_eyes_required`, audited `compliance.rule.change_refused` at\nwarn; the database CHECK refuses it for every writer). Applies the\nchange, writes the revision (reason, both people) and the TM\nprojection, and marks the request approved, all or nothing. 409\n`change_stale` when the rule changed since the request or the\nrequester is no longer active; 409 `not_pending` when decided; 409\n`rule_cap` when the bank would run more than 64 monitoring rules.\nAudit `compliance.rule.change_approved` (700).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "X-Tenant-ID",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "changeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The approved change",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RuleChangeAnswer"
                }
              }
            }
          },
          "403": {
            "description": "`person_required`, `mlro_required` or `four_eyes_required`"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`not_pending`, `change_stale` or `rule_cap`"
          }
        }
      }
    },
    "/api/v1/compliance/rules/changes/{changeId}/reject": {
      "post": {
        "operationId": "rejectComplianceRuleChange",
        "tags": ["ComplianceRules"],
        "summary": "Reject a rule change (second MLRO, with a reason)",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "X-Tenant-ID",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "changeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["reason"],
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 10,
                    "maxLength": 1000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The rejected change",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RuleChangeAnswer"
                }
              }
            }
          },
          "400": {
            "description": "`reason_required`"
          },
          "403": {
            "description": "`person_required`, `mlro_required` or `four_eyes_required`"
          },
          "409": {
            "description": "`not_pending`"
          }
        }
      }
    },
    "/api/v1/compliance/rules/changes/{changeId}/withdraw": {
      "post": {
        "operationId": "withdrawComplianceRuleChange",
        "tags": ["ComplianceRules"],
        "summary": "Withdraw one's own rule change",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "X-Tenant-ID",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "changeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The withdrawn change",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RuleChangeAnswer"
                }
              }
            }
          },
          "403": {
            "description": "`person_required` or `requester_only`"
          },
          "409": {
            "description": "`not_pending`"
          }
        }
      }
    },
    "/api/v1/compliance/rules/backtest": {
      "post": {
        "operationId": "backtestComplianceRule",
        "tags": ["ComplianceRules"],
        "summary": "Test a monitoring rule against the last 30 days",
        "description": "A dry run: the bank's external outgoing transfers of the last 30 days\n(newest 5000) are replayed as of their own time with the shadow\nengine's predicates. Nothing is written. With `rule_id` the rule's\ncurrent settings are replayed too (`current`). Supported: new_payee\nand generic `first`, velocity and generic `gte_count`, generic\n`gte_amount`, structuring_sct, round_amount; other typologies answer\n`supported: false`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "X-Tenant-ID",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "rule_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "typology": {
                    "type": "string"
                  },
                  "condition_compare": {
                    "type": "string",
                    "enum": ["first", "gte_count", "gte_amount", "status"]
                  },
                  "window_hours": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 8760
                  },
                  "threshold_count": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 10000
                  },
                  "threshold_amount": {
                    "type": "integer",
                    "minimum": 0
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The dry run",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RuleBacktest"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/sars": {
      "get": {
        "operationId": "listSars",
        "tags": ["SAR"],
        "summary": "List Suspicious Activity Reports",
        "description": "One page of the tenant's SARs and the total of the filter. Optional\nstatus filter (`open`: draft or locked), the case it was drafted\nfrom, a search over the customer's name, the FIU reference, the\nreport id and the narrative, paging and the order (`deadline`: the\nreporting deadline first, reports without one last). Every row\nnames its customer (`subject_name`) and carries its reporting\ndeadline from detection (`detected_at`: the linked case's opening,\nelse the draft's; `due_at`; `overdue` while not filed) and, after a\nCH filing, the MROS `hold`. A cell MLRO or the platform scope\n(BR-EF-006).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "draft",
                "locked",
                "submitted",
                "acknowledged",
                "withdrawn",
                "open"
              ]
            },
            "description": "Filter by SAR lifecycle status; `open` is draft or locked"
          },
          {
            "name": "case_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Only SARs drafted from this compliance case"
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 200
            },
            "description": "Part of the customer's name, the FIU reference, the report id or the narrative (case-insensitive)"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 200
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100000,
              "default": 0
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["newest", "oldest", "deadline"],
              "default": "newest"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "SAR list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "sars": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Sar"
                      }
                    },
                    "total": {
                      "type": "integer",
                      "description": "Every SAR of the filter"
                    },
                    "limit": {
                      "type": "integer"
                    },
                    "offset": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      },
      "post": {
        "operationId": "createSar",
        "tags": ["SAR"],
        "summary": "Create SAR draft",
        "description": "Creates a new SAR in draft status. Required: subject_type (customer|tenant),\nsubject_id (UUID), narrative. A customer report names a customer of\nthe tenant (422 `subject_not_in_bank`). Optional:\nlinked_transactions (the payments the report covers: transfer ids\nof the tenant, each one a payment of the report's customer, at most\n200; 422 `transactions_not_customer` otherwise), start_date,\nend_date (ISO 8601), case_id (an open case of the tenant; 409\n`case_closed` for a closed one). Without case_id, no_case_reason\n(why there is no case, 10 to 2000 characters) is required: 400\n`no_case_reason_required`; with case_id it is refused. The author is the session's\nofficer (`created_by`, `created_by_id`); an `X-User-Email` header is\nignored. A cell MLRO only: a super_admin is 403\n`platform_read_only`, a service key acting for nobody 403\n`person_required`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SarCreateRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "SAR draft created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Sar"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "422": {
            "description": "`transactions_not_customer` (a linked payment is not the customer's in this tenant) or `subject_not_in_bank`"
          }
        }
      }
    },
    "/api/v1/sars/{sarId}": {
      "get": {
        "operationId": "getSar",
        "tags": ["SAR"],
        "summary": "Get SAR detail",
        "description": "Returns the full SAR record including narrative and linked transactions.\nRestricted to mlro and super_admin roles.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "sarId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "SAR detail",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Sar"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "patch": {
        "operationId": "updateSar",
        "tags": ["SAR"],
        "summary": "Update SAR draft fields",
        "description": "Updates editable fields on a draft SAR (narrative, linked_transactions,\nstart_date, end_date). linked_transactions replaces the draft's\npayments as a whole, with the same check as on create (422\n`transactions_not_customer`). A locked, filed or withdrawn report is\nimmutable: 409 `sar_not_draft` (and the database refuses it for every\nwriter, migration 263). A cell MLRO only.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "sarId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SarUpdateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "SAR updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Sar"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`sar_not_draft`: the report is locked, filed or withdrawn"
          },
          "422": {
            "description": "`transactions_not_customer`: a linked payment is not the customer's in this tenant"
          }
        }
      }
    },
    "/api/v1/sars/{sarId}/lock": {
      "post": {
        "operationId": "lockSar",
        "tags": ["SAR"],
        "summary": "Lock a SAR for filing",
        "description": "draft -> locked: the report's content is immutable from now on. An\nMLRO of the bank's cell who is neither the report's author nor an\nofficer who edited the draft (403 `four_eyes_required`; the database\nrefuses it too, migration 263). Writes a `sar_locked` event on the\nlinked case. 409 `sar_not_draft` for a locked report, `sar_final`\nfor a filed or withdrawn one, `case_closed` when the linked case was\nclosed with anything but a SAR.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "sarId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The locked SAR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Sar"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "`forbidden_role` (staff route gate, DEC-0043), `four_eyes_required`, `mlro_required`, `platform_read_only` or `person_required`"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`sar_not_draft`, `sar_final` or `case_closed`"
          }
        }
      }
    },
    "/api/v1/sars/{sarId}/file": {
      "post": {
        "operationId": "fileSar",
        "tags": ["SAR"],
        "summary": "Record that a SAR was filed with the FIU",
        "description": "locked -> submitted. Records the filing a person made with the\nFinancial Intelligence Unit: the date, the channel (a SAR channel of\nthe bank's licence pack, 422 `invalid_channel` otherwise) and the\nFIU's reference. An MLRO of the cell who is neither the author nor an\neditor of the draft (403 `four_eyes_required`). The date is a day in\nthe bank's time zone: not after today, not before the lock (400\n`filed_before_lock`). In one unit: the report, its filing row for the\nchannel (the case's unclaimed draft row of that channel, else a row\nof its own: one report never overwrites another's reference), a\n`filing` event, and the linked case closed with disposition `sar`\n(which also resolves the alert it decides). A case whose freeze is\nlive, or with a pending second-officer request, stays open\n(`case.close_refused`: `case_freeze_live`, `approval_pending`); a\ncase already closed as SAR stays as it is (`case_closed`). A case\nclosed with anything but a SAR takes no filing (409 `case_closed`).\nThe deadline is measured from detection; `sla_breached` records it.\n\nOn a filed report the call records a further channel (a CH report\ngoes to MROS and to SECO): its own filing row with the date, the\nreference and the officer, a `filing` event and an audit row; the\nreport and its case stay as they are (`case.unchanged: true`). Each\nchannel once per report (409 `channel_already_filed`).\nFor MROS (Switzerland, AMLA Art. 9) the asset hold\nof AMLA Art. 10 is placed for the jurisdiction's\n`sar_hold_business_days` (default 5) working days: `hold.status`\n`placed` with `hold.until`, or `failed` (the filing stands; freeze\nthe funds by hand).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "sarId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["filed_on", "reference", "channel"],
                "properties": {
                  "filed_on": {
                    "type": "string",
                    "format": "date",
                    "description": "Not in the future."
                  },
                  "reference": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "channel": {
                    "type": "string",
                    "description": "A SAR channel of the licence pack (finance_filing_channel)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The filed SAR, its case and the hold",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["sar", "case", "hold"],
                  "properties": {
                    "sar": {
                      "$ref": "#/components/schemas/Sar"
                    },
                    "case": {
                      "type": ["object", "null"],
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "status": {
                          "type": "string"
                        },
                        "closed": {
                          "type": "boolean"
                        },
                        "close_refused": {
                          "type": ["string", "null"],
                          "enum": [
                            "case_freeze_live",
                            "case_closed",
                            "approval_pending",
                            null
                          ]
                        },
                        "unchanged": {
                          "type": "boolean",
                          "description": "A further channel: the case was not touched."
                        }
                      }
                    },
                    "hold": {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "string",
                          "enum": ["placed", "failed", "not_applicable"]
                        },
                        "until": {
                          "type": ["string", "null"]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`invalid_filing`: a date (not in the future) and a reference are required; `filed_before_lock`"
          },
          "403": {
            "description": "`four_eyes_required`, `mlro_required`, `platform_read_only` or `person_required`"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`sar_not_locked`, `sar_final`, `case_closed` or `channel_already_filed`"
          },
          "422": {
            "description": "`invalid_channel`"
          }
        }
      }
    },
    "/api/v1/sars/{sarId}/withdraw": {
      "post": {
        "operationId": "withdrawSar",
        "tags": ["SAR"],
        "summary": "Decide not to file a SAR",
        "description": "draft | locked -> withdrawn, with a rationale of at least 10\ncharacters. The linked case returns to investigating\n(`outcome: investigate`) or closes as no SAR with that rationale\n(`outcome: close_no_sar`; refused while another report of the case\nis pending, under a live freeze, or while a second-officer request\nwaits: 409 `approval_pending`). On a case whose no-SAR close needs a\nsecond officer (DEC-0035 decision 23) the case returns to\ninvestigating and the close is asked of another MLRO of the cell:\n`case.close_refused: pending_approval` and the request in\n`approval`. A report of a case that is already closed (a second\nreport after the first was filed) is withdrawn and the case stays as\nit is (`case.unchanged: true`). A cell MLRO only.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "sarId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["rationale"],
                "properties": {
                  "rationale": {
                    "type": "string",
                    "minLength": 10
                  },
                  "outcome": {
                    "type": "string",
                    "enum": ["investigate", "close_no_sar"],
                    "default": "investigate"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The withdrawn SAR, its case and the second-officer request if one was asked",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["sar", "case", "approval"],
                  "properties": {
                    "sar": {
                      "$ref": "#/components/schemas/Sar"
                    },
                    "case": {
                      "type": ["object", "null"]
                    },
                    "approval": {
                      "oneOf": [
                        {
                          "$ref": "#/components/schemas/CaseApproval"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "A rationale under 10 characters or an unknown outcome"
          },
          "403": {
            "description": "`mlro_required`, `platform_read_only` or `person_required`"
          },
          "409": {
            "description": "`sar_final`, `sar_pending`, `case_freeze_live`, `approval_pending`"
          }
        }
      }
    },
    "/api/v1/sars/{sarId}/submit": {
      "post": {
        "operationId": "submitSar",
        "tags": ["SAR"],
        "summary": "Replaced by lock and file",
        "deprecated": true,
        "description": "Always 410 `sar_submit_replaced`: a report is locked\n(`POST /api/v1/sars/{sarId}/lock`), then its filing is recorded\n(`POST /api/v1/sars/{sarId}/file`), each by an MLRO who is not the\nauthor.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "sarId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "410": {
            "description": "`sar_submit_replaced`"
          }
        }
      }
    },
    "/api/v1/sars/context": {
      "get": {
        "operationId": "getSarContext",
        "tags": ["SAR"],
        "summary": "What a new report on a customer draws on",
        "description": "For drafting a report on one customer of the tenant: the customer\ncard, the customer's open cases (a report links one), the\ncustomer's earlier reports, and the customer's payments in the\nperiod (by the tenant's calendar day; newest first, at most 100;\n`more` when the period holds more). A cell MLRO or the platform\nscope; read-only.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "customer_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 200
            },
            "description": "Part of a payment's reference, description or counterparty"
          }
        ],
        "responses": {
          "200": {
            "description": "The customer's context",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SarContext"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/sars/{sarId}/evidence": {
      "get": {
        "operationId": "getSarEvidence",
        "tags": ["SAR"],
        "summary": "What a report rests on",
        "description": "The evidence the second MLRO reads before locking a report and\nrecording its filing: the customer card (risk level, KYC, frozen\naccounts), the linked case with what opened it (`case_evidence`,\nas on the case), the payments the report names, the alerts behind\nit (the case's alerts and the alert escalated into the draft), the\ncustomer's earlier reports and other cases. A cell MLRO or the\nplatform scope; read-only.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "sarId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The report's evidence",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SarEvidence"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/sars/{sarId}/export": {
      "get": {
        "operationId": "exportSar",
        "tags": ["SAR"],
        "summary": "Export SAR for the Financial Intelligence Unit",
        "description": "Returns a downloadable FIU file. `format=json` (default) is the\nstructured record. A format made for another FIU than the tenant's\nanswers 422.\nFor tenants\nwhose FIU is MROS: `format=goaml` is a goAML v5-shaped XML, `format=mros`\nthe JSON record; a person files it with MROS. No live gateway.\nRestricted to mlro and super_admin roles.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "sarId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "format",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["json", "sepblac", "f19", "mros", "goaml"],
              "default": "json"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "SAR JSON export",
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Sar"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "description": "Export mapper does not match this tenant FIU (WrongFiu)"
          }
        }
      }
    },
    "/api/v1/kyb-cases": {
      "get": {
        "operationId": "listKybCases",
        "tags": ["KYBCases"],
        "summary": "List AI KYB verification cases",
        "description": "Returns all KYB cases for the authenticated tenant, newest first.\nOptional status filter. Restricted to mlro and super_admin roles (BR-EF-013).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "document_pending",
                "document_received",
                "extraction_running",
                "screening_running",
                "pending_review",
                "approved",
                "rejected"
              ]
            },
            "description": "Filter by KYB case status"
          }
        ],
        "responses": {
          "200": {
            "description": "KYB case list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "cases": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/KybCase"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      },
      "post": {
        "operationId": "createKybCase",
        "tags": ["KYBCases"],
        "summary": "Create AI KYB case",
        "description": "Creates a new AI KYB verification case for a customer. The KYB automation\nworkflow is triggered asynchronously after creation.\nRestricted to the bank's mlro. The case's created_by is the session's\nofficer; only a service-key call without a session names the person,\nin X-User-Email (DEC-0043).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["customer_id"],
                "properties": {
                  "customer_id": {
                    "type": "string",
                    "format": "uuid"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "KYB case created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KybCase"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/StaffForbiddenRole"
          }
        }
      }
    },
    "/api/v1/kyb-cases/screen": {
      "post": {
        "operationId": "kybCaseScreen",
        "tags": ["KYBCases"],
        "summary": "UBO screening stub (internal workflow use)",
        "description": "Internal endpoint invoked by the KybAiWorkflow during the UBO screening\nstep. Returns a fixed clear decision in Phase 1 (spike). Will be replaced\nby a real screening provider call once DEC-0003 is resolved.\nRequires X-Service-Key authentication.\n",
        "security": [
          {
            "ServiceKeyAuth": []
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "entity_name": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Screening decision",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "decision": {
                      "type": "string",
                      "enum": ["clear", "hit"]
                    },
                    "match_count": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/kyb-cases/{caseId}": {
      "get": {
        "operationId": "getKybCase",
        "tags": ["KYBCases"],
        "summary": "Get KYB case detail",
        "description": "Returns the full KYB case including AI-extracted entities, screening\nresult, and MLRO decision. Restricted to mlro and super_admin roles.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "caseId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "KYB case detail",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KybCase"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/kyb-cases/{caseId}/status": {
      "post": {
        "operationId": "updateKybCaseStatus",
        "tags": ["KYBCases"],
        "summary": "Update KYB case status (internal workflow use)",
        "description": "Updates the case status. Called exclusively by the KybAiWorkflow\nautomation service via X-Service-Key authentication. Not for direct API consumer use\n\u2014 MLRO decisions use the /decision endpoint instead. The workflow\nnever approves or rejects: `approved` and `rejected` are refused, and\nits view is stored as `ai_suggestion` (a `decision` field from an\nolder build is stored there too), never as the decision.\n",
        "security": [
          {
            "ServiceKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "caseId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["status"],
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "document_received",
                      "extraction_running",
                      "screening_running",
                      "pending_review"
                    ]
                  },
                  "ai_suggestion": {
                    "type": "string",
                    "enum": ["approve", "reject", "escalate"]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Status updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KybCase"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/kyb-cases/{caseId}/decision": {
      "post": {
        "operationId": "recordKybDecision",
        "tags": ["KYBCases"],
        "summary": "Record MLRO decision on KYB case",
        "description": "Records the MLRO's decision (approve/reject/escalate) on a case parked\nfor review, with the officer's reason (10 to 2000 characters). The\nofficer is the session (a service call cannot decide). The decision is\nstored apart from the workflow's `ai_suggestion`, which it never\noverwrites. Restricted to the bank's mlro; the platform scope reads\nonly (DEC-0043).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "caseId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["decision", "reason"],
                "properties": {
                  "decision": {
                    "type": "string",
                    "enum": ["approve", "reject", "escalate"]
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 10,
                    "maxLength": 2000,
                    "description": "The officer's reason (stored in decision_reason)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Decision recorded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KybCase"
                }
              }
            }
          },
          "400": {
            "description": "`{\"error\":\"kyb_reason_required\"}`, or an unknown decision"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "`forbidden_role` (staff route gate, DEC-0043); not an MLRO, a service call, or no officer identity"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`{\"error\":\"kyb_case_decided\"}`: the case is not waiting for review"
          }
        }
      }
    },
    "/api/v1/support/thread": {
      "get": {
        "operationId": "getSupportThread",
        "tags": ["Support"],
        "summary": "The customer's support thread and newest messages (poll)",
        "description": "[P1] Customer JWT, own profile. The thread state (customer status,\n`ai_enabled`, `disclosure_required`, assignee, expected reply, unread\ncount, complaint acknowledgement, CSAT ask, `support_availability`)\nand the newest page of messages, oldest first. This is the poll: every 2 s while\n`ai_answering`, every 4 s otherwise, only while the thread is on\nscreen, with `If-None-Match`. No conversation yet: 200 with\n`id: null` and no messages. Reading never moves the read marker.\nImpersonation sessions may read. Rate limit 60 per minute per\ncustomer together with `GET /thread/messages`.\n\n0.33.0 (one topic, one thread; DEC-0033 amendment 2026-10-05): a\ncustomer may hold several chat conversations. Every `/thread*` route\naddresses the newest chat conversation that has an open case, else\nthe newest chat conversation (the \"current\" one); shapes are\nunchanged. Kept for the mobile app until it ships the thread\nroutes; the portal uses `/chats/{threadId}*`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportMessageLimit"
          },
          {
            "$ref": "#/components/parameters/SupportIfNoneMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "The thread",
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/SupportETag"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportThread"
                }
              }
            }
          },
          "304": {
            "$ref": "#/components/responses/SupportNotModified"
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/thread/messages": {
      "get": {
        "operationId": "listSupportThreadMessages",
        "tags": ["Support"],
        "summary": "Older messages, or messages newer than a cursor",
        "description": "[P1] `before` pages back (`next_cursor`, `has_more`); `after` reads\nnewer messages (`latest_cursor`, `has_more_newer`); neither gives\nthe newest page; both is 400 `invalid_cursor`. Pages are oldest\nfirst. ETag and 304 as `GET /thread`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportBefore"
          },
          {
            "$ref": "#/components/parameters/SupportAfter"
          },
          {
            "$ref": "#/components/parameters/SupportMessageLimit"
          },
          {
            "$ref": "#/components/parameters/SupportIfNoneMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of messages",
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/SupportETag"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportMessagePage"
                }
              }
            }
          },
          "304": {
            "$ref": "#/components/responses/SupportNotModified"
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      },
      "post": {
        "operationId": "postSupportThreadMessage",
        "tags": ["Support"],
        "summary": "The customer writes in the support thread",
        "description": "[P1] Stores the message (encrypted) and moves the case (ARCH-029a\n\u00a73.5): no open case opens one, `ai_handling` when the AI may answer\n(the AI turn is dispatched to Restate), else `queued` for a person;\n`waiting_customer` goes back to `assigned`; a `resolved` case\nreopens before `reopen_until`. Restate unreachable: the case is\nqueued for a person and the answer is still 202. 0.33.0: the\nmessage goes to the current chat conversation (`GET /thread`);\nwhen no chat is open it starts a new chat conversation (as\n`POST /chats`, without the open-chat cap).\n\nIdempotent on `client_message_id`: the same id, body, `context` and\n`intent` answer 202 with the same message; another body, another\ncontext or another chip is 409 `idempotency_key_reused` (0.28.1: the\ncontext and the chip count, so a retry never replays a message about\nanother payment). Body 1 to 4000 characters after trimming\n(422 `blank`, `too_long`, `invalid_characters`). Card data is\nrefused before anything is stored (422 `card_data_refused`, PCI): a\nLuhn-valid card number of 13 to 19 digits (in one block or in groups\nseparated by spaces, hyphens or dots; invisible format characters\nignored), or a CVV/CVC/security code or an expiry date after its cue\nword (EN, ES, DE, PT, AR, CA). IBANs, amounts, dates and phone\nnumbers pass. `context` is never\nshown to the customer; an id that is not the customer's is dropped,\nand with an `intent` it is 422 `invalid_field` `context.id` (0.28.1).\nWhether the bank holds the payment changes nothing the customer\nsees or the route the message takes (0.28.1, DEC-0032 amendment\n2026-10-04); staff see the case's `flags.compliance_linked`.\nImpersonation: 403 `read_only_session`. Rate limit 10 per minute,\n300 per day.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportPostMessageRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Stored (or the stored message of a replay)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportMessage"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/thread/handoff": {
      "post": {
        "operationId": "requestSupportHandoff",
        "tags": ["Support"],
        "summary": "Talk to a person, or make a complaint",
        "description": "[P1] One tap, no confirmation for a person (Ley 10/2025).\n`customer_request` queues the case for a person (an AI case hands\noff; a case already with a person changes nothing).\n`complaint` does the same and registers the case as a complaint\nnow (statutory clock, `complaint_registered` message). Idempotent\nby state. Answers the thread as `GET /thread`. Impersonation: 403\n`read_only_session`. Rate limit 10 per hour.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportHandoffRequest"
              },
              "example": {
                "reason": "customer_request"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The thread after the handoff",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportThread"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/thread/read": {
      "post": {
        "operationId": "markSupportThreadRead",
        "tags": ["Support"],
        "summary": "Move the read marker (clears the unread count)",
        "description": "[P1] Moves the marker to `up_to` when it is newer than the current\none; an older id changes nothing. 422 `unknown_message` for an id\nthat is not a message of this thread. Impersonation: 403.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportReadRequest"
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Marker moved (or already further)"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          }
        }
      }
    },
    "/api/v1/support/thread/csat": {
      "post": {
        "operationId": "rateSupportCase",
        "tags": ["Support"],
        "summary": "Rate the last resolved case (1 to 5)",
        "description": "[P1] Only while the last case is `resolved` (409 `not_resolved`),\nonce (409 `already_rated`). Comment at most 500 characters.\nImpersonation: 403.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportCsatRequest"
              },
              "example": {
                "score": 4,
                "comment": "R\u00e1pido y claro."
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Rating stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportCsatResult"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          }
        }
      }
    },
    "/api/v1/support/thread/complaint/withdraw": {
      "post": {
        "operationId": "withdrawSupportThreadComplaint",
        "tags": ["Support"],
        "summary": "The customer withdraws the chat's complaint (ARCH-030 \u00a75.10)",
        "description": "The thread's open complaint (ARCH-029a \u00a73.6). `confirm` must be true\n(422 `confirmation_required`): clients show a confirmation step\nfirst. No open complaint: 409 `not_withdrawable`; answered by a\nfinal reply: 409 `already_final`; already withdrawn: 409\n`already_withdrawn`. Effects of ARCH-030 \u00a74.4 in one transaction:\nregister event `withdrawn`, `outcome` `withdrawn`, the chat case\n`closed` (close reason `complaint_withdrawn`), every timer stopped,\nsystem message `complaint_withdrawn`, the confirmation letter\n(`complaint_withdrawal_confirmation`, durable medium, ARCH-030 \u00a79.3,\nwith its `letter_issued` message and e-mail), audit\n`support.complaint.withdrawn`, the `complaint_withdrawn` e-mail. The\nletter may follow (DEC-0033 amendment 2026-10-06): when it cannot\nbe issued now (no document store with Object Lock, or storing it\nfailed) the withdrawal still answers 200 and the letter is issued\nlater (0.33.1: at startup and hourly once letters are available,\nthe daily reconcile as a backstop), with the withdrawal date; it then\nappears in Documents with its `letter_issued` message and e-mail.\nCannot be undone; the next customer message opens a new case and a\nnew complaint gets a new reference and clock. Idempotent on\n`client_request_id` (a replay answers 200; another body 409\n`idempotency_key_reused`). Impersonation: 403 `read_only_session`.\n30 per hour per customer, with the ticket submissions and\nwithdrawals. Deprecated for the portal (DEC-0033 decision 22: the\ncustomer writes, staff record it); kept with `can.withdraw_complaint`\nfor the mobile app until it ships the plain complaint line.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportWithdrawTicketRequest"
              },
              "example": {
                "client_request_id": "6d7e8f9a-0b1c-4d2e-8f3a-4b5c6d7e8f9a",
                "confirm": true,
                "reason": "Solved by the merchant."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The thread after the withdrawal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportThread"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/thread/close": {
      "post": {
        "operationId": "closeSupportThread",
        "tags": ["Support"],
        "summary": "The customer ends the open conversation (ARCH-030 \u00a74.5)",
        "description": "DEC-0033 amendment 2026-10-04. Ends the chat's open case in any\nstatus (`ai_handling`, `queued`, `assigned`, `waiting_customer`,\n`escalated`, `reopened`, `resolved`): the case `closed` (no close\nreason on a chat case), the reopen window and a pause cleared,\nevery timer stopped, the case event `closed` with `closed_by`\n`customer`, the system message `closed` with\n`params: { \"closed_by\": \"customer\" }` (\"You closed this\nconversation.\"), never unread for the customer, an audit row\n`support.case.status_changed`. The thread's `can.close` tells\nclients when to offer it. No open case: 409 `not_closable`; a\ncomplaint: 409 `complaint_not_closable` (it ends by the bank's\nfinal reply or by `POST /thread/complaint/withdraw`). The\ntipping-off lock changes nothing for the customer. The next\ncustomer message starts a new chat conversation (0.33.0; before:\na new case in the same conversation).\nIdempotent on `client_request_id` (a replay answers 200 with the\nthread). Impersonation: 403 `read_only_session`. 10 per hour per\ncustomer. For any thread, complaints included, see\n`POST /chats/{threadId}/close`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportThreadCloseRequest"
              },
              "example": {
                "client_request_id": "7e8f9a0b-1c2d-4e3f-8a4b-5c6d7e8f9a0b"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The thread after the close (status `closed`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportThread"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/thread/feedback": {
      "post": {
        "operationId": "postSupportThreadFeedback",
        "tags": ["Support"],
        "summary": "\"Did that help?\" under an AI answer (0.27.0, ARCH-029a \u00a73.8a)",
        "description": "DEC-0033 decision 29, ARCH-030 \u00a74.6. The customer answers the\nquestion the thread asks (`resolution_prompt`) under the assistant's\nnewest answer. `helped: true` on that very message resolves the\nAI-only chat case as the customer's own act: status `resolved`,\n`reopen_until` after `reopen_window_days` (as a staff resolution),\nthe case event `status` and the system message `resolved` with\n`params.resolved_by: customer` (\"You said this helped. Thanks!\"),\nnever unread for the customer, `csat.asked` when the bank rates, an\naudit row `support.case.status_changed`. `helped: false`, an earlier\nanswer, a case a person has or had, or a complaint: the answer is\nonly recorded (no state change). One answer per message (a second\none changes nothing, 200). A tipping-off-locked case reads exactly\nlike any other: the rule follows the status the customer sees, and\nthe customer's own resolution and what follows from it alone are\nnever masked. Idempotent on `client_request_id` (a replay answers\n200 with the thread; the id for another request: 409\n`idempotency_key_reused`). Not an AI answer of this thread: 422\n`unknown_message`. Impersonation: 403 `read_only_session`. 30 per\nhour per customer.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportThreadFeedbackRequest"
              },
              "example": {
                "message_id": "1f2e3d4c-5b6a-4798-8a7b-6c5d4e3f2a1b",
                "helped": true,
                "client_request_id": "7e8f9a0b-1c2d-4e3f-8a4b-5c6d7e8f9a0b"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The thread after the answer (`resolved` when it resolved the case)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportThread"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/chats": {
      "post": {
        "operationId": "startSupportChat",
        "tags": ["Support"],
        "summary": "Start a new chat (a new thread) with its first message (0.33.0)",
        "description": "DEC-0033 amendment 2026-10-05 (one topic, one thread). A thread is\none case: a chat, a request (ticket) or a complaint. A new chat is a\nnew conversation with exactly one case; the message takes the path\nof a first message on `POST /thread/messages` (ARCH-029a \u00a73.5):\n`ai_handling` with the AI turn dispatched when the tenant's AI\npolicy lets the assistant answer (the same gates: `support_ai`,\nkill switches, token cap, circuit breaker, turns per customer and\nhour), else `queued` for a person. Body, `context`, `intent`,\n`client_actions`, card-data refusal and text rules as\n`POST /thread/messages`.\n\nSeveral threads may be open at once; at most 5 open chat threads per\ncustomer (a chat whose case is not closed): the sixth is 409\n`too_many_open_chats` (close one first). Idempotent on\n`client_message_id` over all the customer's chats: the same id and\nbody answer 201 with the thread it started; another body, context or\nchip is 409 `idempotency_key_reused`. Impersonation: 403\n`read_only_session`. Rate limits: 10 messages per minute and 300 per\nday together with every customer message, and 20 new chats per\nhour. Feature `support_chat` (404 `support_disabled`).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportPostMessageRequest"
              },
              "example": {
                "client_message_id": "c3d1e2f0-1a2b-4c3d-8e9f-0a1b2c3d4e5f",
                "body": "My card payment was declined at a shop."
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The new thread (or the thread of a replay)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportChat"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/chats/{threadId}": {
      "get": {
        "operationId": "getSupportChat",
        "tags": ["Support"],
        "summary": "One chat thread, its state and its newest messages (poll)",
        "description": "0.33.0. The thread (a chat case of the customer, `thread_id` of\n`GET /conversations`) with the newest page of that case's messages\nonly, oldest first, masked as `GET /thread` (tipping-off rules\nunchanged). `status` is the plain state of the conversations list;\n`waiting` says who has it and what happens next: `assistant` (the AI\nis answering), `person` (waiting for a person;\n`expected_reply_by` is the next opening of the bank's hours when it\nis closed now, else null: \"as soon as we can\"), `you` (the bank\nwaits for the customer), `none` (nothing pending, or done). `can`\ntells clients what to offer. A closed thread is read-only (start a\nnew chat). Poll as `GET /thread` (2 s while `waiting` is\n`assistant`, else 4 s, with `If-None-Match`). A request (ticket),\nanother customer's or an unknown id: 404 `not_found`. Impersonation\nreads. 60 reads per minute per customer with the other thread reads.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportThreadId"
          },
          {
            "$ref": "#/components/parameters/SupportMessageLimit"
          },
          {
            "$ref": "#/components/parameters/SupportIfNoneMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "The thread",
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/SupportETag"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportChat"
                }
              }
            }
          },
          "304": {
            "$ref": "#/components/responses/SupportNotModified"
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/chats/{threadId}/messages": {
      "get": {
        "operationId": "listSupportChatMessages",
        "tags": ["Support"],
        "summary": "Older or newer messages of one chat thread",
        "description": "0.33.0. As `GET /thread/messages`, for this thread's case only. The\n`m1.` cursors belong to the thread: another thread's cursor is 400\n`invalid_cursor`. ETag and 304.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportThreadId"
          },
          {
            "$ref": "#/components/parameters/SupportBefore"
          },
          {
            "$ref": "#/components/parameters/SupportAfter"
          },
          {
            "$ref": "#/components/parameters/SupportMessageLimit"
          },
          {
            "$ref": "#/components/parameters/SupportIfNoneMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of messages",
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/SupportETag"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportMessagePage"
                }
              }
            }
          },
          "304": {
            "$ref": "#/components/responses/SupportNotModified"
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      },
      "post": {
        "operationId": "postSupportChatMessage",
        "tags": ["Support"],
        "summary": "The customer replies in one chat thread",
        "description": "0.33.0. As `POST /thread/messages`, on this thread's case: an AI case\ngets the AI turn under the policy; a `resolved` case inside its\nreopen window reopens (existing rule); a case with people gets no AI\nanswer. While the thread waits for a person, the reply gets an\nimmediate system line `message_received` with\n`params.expected_reply_by` (date-time or null, as the thread's\n`expected_reply_by`); one per waiting period (none again until a\nperson, the assistant or a handoff wrote), never unread. A closed\nthread (and a resolved one past its reopen window) is read-only:\n409 `thread_closed` (start a new chat). Idempotent on\n`client_message_id` within the thread's conversation (202 with the\nstored message; another body or another thread: 409\n`idempotency_key_reused`). Impersonation: 403 `read_only_session`.\n10 per minute and 300 per day with every customer message.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportThreadId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportPostMessageRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Stored (or the stored message of a replay)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportMessage"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/chats/{threadId}/handoff": {
      "post": {
        "operationId": "requestSupportChatHandoff",
        "tags": ["Support"],
        "summary": "Talk to a person, or make a complaint, on this thread",
        "description": "0.33.0. As `POST /thread/handoff`, on this thread's case (one tap,\nno confirmation; `complaint` registers this case as a complaint).\nA closed thread: 409 `thread_closed`. Answers the thread.\nImpersonation: 403 `read_only_session`. 10 per hour.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportThreadId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportHandoffRequest"
              },
              "example": {
                "reason": "customer_request"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The thread after the handoff",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportChat"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/chats/{threadId}/read": {
      "post": {
        "operationId": "markSupportChatRead",
        "tags": ["Support"],
        "summary": "Move the read marker of this thread",
        "description": "0.33.0. As `POST /thread/read`; `up_to` must be a message of this\nthread (else 422 `unknown_message`). Only forward. Impersonation:\n403 `read_only_session`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportThreadId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportReadRequest"
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Marker moved (or already further)"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/chats/{threadId}/close": {
      "post": {
        "operationId": "closeSupportChat",
        "tags": ["Support"],
        "summary": "End this thread (\"it's sorted\"), or withdraw its complaint",
        "description": "0.33.0, DEC-0033 amendment 2026-10-05 (D4). The customer may end an\nopen thread in any status (`ai_handling`, `queued`, `assigned`,\n`waiting_customer`, `escalated`, `reopened`, `resolved`). `reason`:\n`resolved` (\"It's sorted\") or `no_longer_needed`, kept with the\ncase's `closed` event. A chat: as `POST /thread/close` (the case\n`closed`, `closed_by` customer, every timer stopped, the system\nmessage `closed`, the assignee, watchers and MLRO told).\n\nA complaint (`kind` `complaint`, `can.close_withdraws_complaint`):\nclosing withdraws it (ARCH-030 \u00a74.4, as\n`POST /thread/complaint/withdraw`: the register records it withdrawn\nby the customer in the app, the SAC officer is told, the\nconfirmation letter is issued, cannot be undone) and needs\n`confirm: true` after the client showed the consequence; without it\n409 `confirm_required`, nothing changes. A complaint answered by its\nfinal reply ends like a chat. The confirmation letter may follow\nthe withdrawal (DEC-0033 amendment 2026-10-06): the withdrawal\nnever fails over it; a letter that cannot be issued now is issued\nlater, hourly once letters are available (0.33.1).\n\nThe tipping-off lock changes nothing the customer sees (a locked\ncase the bank closed still reads open and is ended the same way).\nAlready closed: 409 `thread_closed`. Idempotent on\n`client_request_id` (a replay answers 200 with the thread; the id of\nanother request or thread: 409 `idempotency_key_reused`).\nImpersonation: 403 `read_only_session`. 10 per hour per customer\nwith `POST /thread/close`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportThreadId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportChatCloseRequest"
              },
              "example": {
                "client_request_id": "7e8f9a0b-1c2d-4e3f-8a4b-5c6d7e8f9a0b",
                "reason": "resolved"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The thread after the close (`open` false)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportChat"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/chats/{threadId}/csat": {
      "post": {
        "operationId": "rateSupportChat",
        "tags": ["Support"],
        "summary": "Rate this thread's resolved case (1 to 5)",
        "description": "0.33.0. As `POST /thread/csat`, for this thread's case\n(`can.rate`): 409 `not_resolved` unless the customer sees it\nresolved, 409 `already_rated` once rated. Impersonation: 403.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportThreadId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportCsatRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Rating stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportCsatResult"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/chats/{threadId}/feedback": {
      "post": {
        "operationId": "postSupportChatFeedback",
        "tags": ["Support"],
        "summary": "\"Did that help?\" under an AI answer of this thread",
        "description": "0.33.0. As `POST /thread/feedback`, for an AI answer of this thread\n(`resolution_prompt`, `can.feedback`); another thread's message is\n422 `unknown_message`. Answers the thread. Impersonation: 403.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportThreadId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportThreadFeedbackRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The thread after the answer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportChat"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/conversations": {
      "get": {
        "operationId": "listSupportConversations",
        "tags": ["Support"],
        "summary": "The customer's chats and requests in one list (0.27.0, ARCH-030 \u00a75.15)",
        "description": "DEC-0033 decision 30. Every case of the chat thread and every ticket\nof the customer, newest visible activity first, in plain states:\n`answered`, `waiting_for_us`, `waiting_for_you`, `done`. The state is\nthe one the customer sees: a chat case maps the thread's status\n(ARCH-029a \u00a73.2, with the tipping-off rules: a locked case reads\nwaiting or assigned once it moved, a locked case the bank closed\nstill reads waiting, the customer's own close and resolution read\nthe same on every case); an earlier case of the thread is `done`; a\nrequest maps its ticket status (ARCH-030 \u00a74.1). Last activity, last\nauthor and unread count read only the messages the customer is\nshown. No reference, queue, reason or case type; an AI answer is\nnever previewed. Chat rows need `support_chat`, request rows\n`support_tickets`; both off: 404 `support_disabled`. Keyset cursor\n`v1.`; ETag over the answer (304). Impersonation reads. 60 per minute\nper customer.\n\n0.33.0 (one topic, one thread): one row per thread. Every chat case\nof every chat conversation of the customer (a new chat is its own\nconversation; an older conversation with several cases gives one\nrow per case) and every ticket. New fields: `thread_id` (the case\nid, as `id`), `kind` `complaint` for a chat registered as a\ncomplaint (its thread is `/chats/{thread_id}`; a request that is a\ncomplaint stays `request`, its page is `/tickets/{id}`), `open`\n(the thread accepts a reply and can be ended) and `can_close` (a\nchat or complaint: `POST /chats/{thread_id}/close`; a request:\n`POST /tickets/{id}/withdraw`, its `can.withdraw` or\n`can.withdraw_complaint`; a request the bank opened is the bank's\nrequest and is never withdrawn by the customer). The page adds\n`unread_total` (every unread line of every thread, the portal's\nbadge) and `new_chat.assistant` (the assistant would answer a new\nchat now: the AI disclosure before the first message).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 20
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 512
            }
          },
          {
            "name": "If-None-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One page of conversations",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportConversationPage"
                }
              }
            }
          },
          "304": {
            "description": "Not modified"
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/help": {
      "get": {
        "operationId": "searchSupportHelp",
        "tags": ["Support"],
        "summary": "Search the tenant's published help articles",
        "description": "[P2] Postgres full-text search in the locale's configuration; no\n`query` lists the newest. Customer JWT. Rate limit 30 per minute.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "query",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          },
          {
            "name": "locale",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/SupportLocale"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 10,
              "default": 5
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Matching articles",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportHelpSearchResult"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          }
        }
      }
    },
    "/api/v1/support/help/{articleId}": {
      "get": {
        "operationId": "getSupportHelpArticle",
        "tags": ["Support"],
        "summary": "One published help article",
        "description": "[P2] An unpublished or other tenant's article is 404 `not_found`.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "articleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The article",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportHelpArticle"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          }
        }
      }
    },
    "/api/v1/support/summary": {
      "get": {
        "operationId": "getSupportSummary",
        "tags": ["SupportTickets"],
        "summary": "Badges of the thread, the tickets and the letters in one call",
        "description": "`enabled` mirrors the tenant features `support_chat` and\n`support_tickets`; a disabled part has zero counts. Never 404 for a\ndisabled feature. `tickets.waiting_for_you` counts active tickets\nwhose status is `waiting_for_you`; `next_due_date` is the nearest\ndue date of an open required request, a calendar date in\n`time_zone`. `letters.unread`: letters the customer has not\ndownloaded yet (any feature state).\nETag and 304. Rate limit 60 per minute per customer together with\n`GET /support/tickets*`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportIfNoneMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "The badges",
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/SupportETag"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportSummary"
                },
                "example": {
                  "thread": {
                    "enabled": true,
                    "unread": 0
                  },
                  "tickets": {
                    "enabled": true,
                    "active": 2,
                    "waiting_for_you": 1,
                    "unread": 3,
                    "next_due_date": "2026-12-24",
                    "time_zone": "Europe/Madrid"
                  },
                  "letters": {
                    "unread": 0
                  }
                }
              }
            }
          },
          "304": {
            "$ref": "#/components/responses/SupportNotModified"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/tickets": {
      "get": {
        "operationId": "listSupportTickets",
        "tags": ["SupportTickets"],
        "summary": "The customer's tickets, active or past",
        "description": "`active` (open, waiting_for_you, in_progress): `waiting_for_you`\nfirst, then the due date ascending (none last), then the last\nactivity, newest first. `past` (resolved, closed, cancelled): the\nnewest end first. Keyset cursor `k1.`; a cursor of the other state\nor a malformed one is 400 `invalid_cursor`. Chat cases are never\nlisted. `support_availability` (0.26.0): when people of the bank\nanswer, as on the thread. ETag from the newest `updated_at` of the\ncustomer's tickets, their count, the query and the\n`support_availability` block; 304.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportTicketState"
          },
          {
            "$ref": "#/components/parameters/SupportTicketListLimit"
          },
          {
            "$ref": "#/components/parameters/SupportTicketCursor"
          },
          {
            "$ref": "#/components/parameters/SupportIfNoneMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of tickets",
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/SupportETag"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportTicketList"
                }
              }
            }
          },
          "304": {
            "$ref": "#/components/responses/SupportNotModified"
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      },
      "post": {
        "operationId": "openSupportTicket",
        "tags": ["SupportTickets"],
        "summary": "The customer opens a ticket",
        "description": "One transaction: the ticket's conversation and case (`queued`,\ntype and queue from the topic, first-response clock), the\n`ticket_opened` system message, the body as the first customer\nmessage. Topic `complaint`: registered now, received at the first\nmessage (statutory clock, `complaint_registered` message and\ne-mail); `personal_data`: the data-request clock. `context` that is\nnot the customer's is dropped silently and is shown back as `link`.\n\nIdempotent on `client_ticket_id`: the same id and body answer 201\nwith the same ticket; another body is 409 `idempotency_key_reused`.\nAt most `customer_open_ticket_limit` (default 10) open tickets the\ncustomer opened: 409 `too_many_open_tickets` with `limit`. Body as\nthe thread (ARCH-029a \u00a70.3; 422 `blank`, `too_long`,\n`invalid_characters`) and card data refused (422\n`card_data_refused`). `upload_ids` (0 to 5): uploads are\n`SF-tickets-files`; until they exist any id is 422\n`upload_not_found`. Rate limit 10 per hour, 30 per day.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportOpenTicketRequest"
              },
              "example": {
                "client_ticket_id": "7d2b0c1e-4a5f-4e8b-9c3d-2f1a0b9c8d7e",
                "topic": "payments",
                "subject": "Transfer to my landlord not received",
                "body": "I sent 850 EUR on 3 December and the landlord says nothing arrived.",
                "context": {
                  "kind": "transaction",
                  "id": "00000000000000000000000000a1b2c3"
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The ticket (also the answer of a replay)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportTicket"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/tickets/topics": {
      "get": {
        "operationId": "listSupportTicketTopics",
        "tags": ["SupportTickets"],
        "summary": "The topics a customer may open a ticket on",
        "description": "Active topics in the tenant's order; clients name topics by `code`.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Topics",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportTicketTopics"
                },
                "example": {
                  "topics": [
                    {
                      "code": "account",
                      "attachments": true
                    },
                    {
                      "code": "payments",
                      "attachments": true
                    },
                    {
                      "code": "complaint",
                      "attachments": true
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/tickets/{ticketId}": {
      "get": {
        "operationId": "getSupportTicket",
        "tags": ["SupportTickets"],
        "summary": "One ticket with its requests and newest messages (poll)",
        "description": "The ticket, every request by `seq`, and the newest page of\nmessages, oldest first, with `support_availability` (0.26.0). ETag\n(including the `support_availability` block) and 304; poll every\n10 s while the ticket is on screen. Reading never moves the read\nmarker.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportTicketId"
          },
          {
            "$ref": "#/components/parameters/SupportMessageLimit"
          },
          {
            "$ref": "#/components/parameters/SupportIfNoneMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "The ticket",
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/SupportETag"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportTicket"
                }
              }
            }
          },
          "304": {
            "$ref": "#/components/responses/SupportNotModified"
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/tickets/{ticketId}/messages": {
      "get": {
        "operationId": "listSupportTicketMessages",
        "tags": ["SupportTickets"],
        "summary": "Older messages of a ticket, or messages newer than a cursor",
        "description": "As `GET /support/thread/messages`, with `m1.` cursors of the ticket's conversation; a cursor of another conversation is 400 `invalid_cursor`.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportTicketId"
          },
          {
            "$ref": "#/components/parameters/SupportBefore"
          },
          {
            "$ref": "#/components/parameters/SupportAfter"
          },
          {
            "$ref": "#/components/parameters/SupportMessageLimit"
          },
          {
            "$ref": "#/components/parameters/SupportIfNoneMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of messages",
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/SupportETag"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportTicketMessagePage"
                }
              }
            }
          },
          "304": {
            "$ref": "#/components/responses/SupportNotModified"
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      },
      "post": {
        "operationId": "postSupportTicketMessage",
        "tags": ["SupportTickets"],
        "summary": "The customer writes in a ticket",
        "description": "`waiting_customer` goes back to `assigned`; open statuses run the\nnext-response clock; `resolved` before `reopen_until` reopens the\nticket (to its last assignee if still eligible); `closed`, or\n`resolved` after `reopen_until`: 409 `ticket_closed`. Text,\nidempotency on `client_message_id` and card data as the thread\n(ARCH-029a \u00a73.5). `upload_ids` as `POST /support/tickets`. Rate\nlimit 10 per minute and 300 per day, shared with the thread.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportTicketId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportTicketMessageRequest"
              },
              "example": {
                "client_message_id": "9b1c2d3e-4f50-4617-8293-a4b5c6d7e8f9",
                "body": "Please send the card to my office."
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Stored (or the stored message of a replay)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportTicketMessage"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/tickets/{ticketId}/requests/{requestId}/submit": {
      "post": {
        "operationId": "submitSupportTicketRequest",
        "tags": ["SupportTickets"],
        "summary": "The customer answers a request of the bank",
        "description": "By kind: `answer` needs `answer` (1 to 4000; 422\n`answer_required`); `confirm` needs `confirm` true or false (422\n`confirm_required`); `documents` needs `files`, `min_files` to\n`max_files` (422 `files_required`, `too_many_files` with `limit`),\neach `document_type` in the request's list (one type: may be\nomitted; else 422 `document_type_not_allowed`), `answer` an\noptional comment (1 to 1000). Fields of another kind are 422\n`invalid_field`. Uploads are `SF-tickets-files`: until they exist\nevery upload id is 422 `upload_not_found`.\n\nThe request must be `pending` or `rejected` (409\n`request_not_open`); a closed ticket is 409 `ticket_closed`.\nEffects: attempt + 1, `submitted` (`accepted` at once when the\nrequest needs no review, the default of `confirm`), system\nmessages, case event `request_submitted`; a ticket waiting for the\ncustomer moves on once no required request is open (the review\nclock runs). Idempotent on `client_submission_id` per request: the\nsame body answers 200 with the request; another body is 409\n`idempotency_key_reused`. Rate limit 30 per hour together with\nwithdrawals.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportTicketId"
          },
          {
            "$ref": "#/components/parameters/SupportRequestId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportSubmitRequest"
              },
              "example": {
                "client_submission_id": "1b2c3d4e-5f60-4718-8293-a4b5c6d7e8f9",
                "files": [
                  {
                    "upload_id": "3e4f5a6b-7c8d-4e9f-a0b1-c2d3e4f5a6b7",
                    "document_type": "proof_of_address"
                  }
                ],
                "answer": "Electricity bill of November."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The request after the submission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportTicketRequest"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/tickets/{ticketId}/withdraw": {
      "post": {
        "operationId": "withdrawSupportTicket",
        "tags": ["SupportTickets"],
        "summary": "The customer withdraws a ticket it opened, or the complaint of a complaint ticket",
        "description": "`confirm` must be true (422 `confirmation_required`): clients show\na confirmation step first. A ticket the customer opened, not a\ncomplaint, still open (not resolved, not closed): `closed` with\nclose reason `withdrawn` (status `cancelled`), its open requests\ncancelled, system message `ticket_withdrawn`. A bank ticket, a\nresolved ticket (it keeps its outcome; DEC-0033 amendment\n2026-10-04) or a ticket closed otherwise: 409 `not_withdrawable`; already withdrawn: 409 `already_withdrawn`. A\ncomplaint ticket: the complaint withdrawal of ARCH-030 \u00a74.4 (the\nticket `closed` with close reason `complaint_withdrawn`, status\n`cancelled`, `complaint.outcome` `withdrawn`, register event,\ntimers stopped, system message `complaint_withdrawn`, the\nconfirmation letter, which may follow later: the withdrawal never\nfails over it, DEC-0033 amendment 2026-10-06); answered by\na final reply: 409 `already_final`; already withdrawn: 409\n`already_withdrawn`. Cannot be undone. Idempotent on `client_request_id`: a replay answers 200 with the\nticket; another body is 409 `idempotency_key_reused`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportTicketId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportWithdrawTicketRequest"
              },
              "example": {
                "client_request_id": "5c6d7e8f-9a0b-4c1d-8e2f-3a4b5c6d7e8f",
                "confirm": true,
                "reason": "The card arrived today."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The ticket after the withdrawal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportTicket"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/tickets/{ticketId}/read": {
      "post": {
        "operationId": "markSupportTicketRead",
        "tags": ["SupportTickets"],
        "summary": "Move the ticket's read marker forward",
        "description": "As `POST /support/thread/read`: to that message when it is newer\nthan the current marker; an older id changes nothing. 422\n`unknown_message` for a message of another conversation. The\ncustomer's own writes move the marker past the messages they made.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportTicketId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportReadRequest"
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Done"
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/uploads": {
      "post": {
        "operationId": "createSupportUpload",
        "tags": ["SupportTickets"],
        "summary": "Upload a file for a ticket (ARCH-030 \u00a75.13, \u00a78.2)",
        "description": "Raw body (no JSON, no multipart), at most 10 MB. Pipeline: rate\nlimit (30 per hour and 200 MB per day per customer, fail closed),\nheader checks, `Content-Length` before reading; SHA-256; magic\nbytes against `Content-Type` and the checks of \u00a78.1; the scanner\nport (`SUPPORT_SCAN_MODE` `none`: `scan` `not_scanned`); per-file\nAES-256-GCM encryption and the object store (SSE-C); the row. An\nunattached upload is deleted after 24 h; attach it with\n`upload_ids` on a ticket, a message or a submission. Feature\n`support_tickets` off: 404 `tickets_disabled`; impersonation: 403\n`read_only_session`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Content-Type",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "enum": ["application/pdf", "image/jpeg", "image/png"]
            },
            "description": "Declared type; must agree with the magic bytes (else 422 `file_refused` `type_mismatch`)."
          },
          {
            "name": "Content-Length",
            "in": "header",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 10485760
            },
            "description": "Checked before the body is read (413 `file_too_large`)."
          },
          {
            "name": "X-Client-Upload-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Unique per uploader. A replay with the same SHA-256 answers 200 with the first upload; another SHA-256 is 409 `idempotency_key_reused`."
          },
          {
            "name": "X-File-Name",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 2048
            },
            "description": "UTF-8, percent-encoded. Stored as NFC, last path segment, control and bidi characters removed, at most 120 characters, an extension of the detected type; empty `document.<ext>`."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/pdf": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            },
            "image/jpeg": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            },
            "image/png": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportUpload"
                }
              }
            }
          },
          "200": {
            "description": "A replay of the same upload (same `X-Client-Upload-Id` and SHA-256)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportUpload"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_field` (with `field`): a missing or malformed `X-Client-Upload-Id`, `X-File-Name` or `Content-Length` (an empty body, or a body shorter than declared).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "413": {
            "description": "`file_too_large` (with `limit` 10485760), answered on `Content-Length` before the body is read.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          },
          "415": {
            "description": "`unsupported_file_type` (with `allowed`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          },
          "422": {
            "description": "`file_refused` with `note` (`file_refusal`): `type_mismatch`\n(magic bytes, structure, a format hidden inside an image),\n`pdf_encrypted`, `pdf_active_content` (/JavaScript, /JS,\n/Launch, /EmbeddedFile, /RichMedia, /XFA, /OpenAction or /AA with\nan action, also inside object streams; an object stream that\ncannot be checked; more than 50 MB inflated), `image_too_large`\n(over 50 megapixels by the header), `malware` (scanner only).\nNothing is stored for a refused file.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          },
          "503": {
            "description": "`support_unavailable`: no file store, the object store failed, or 8 uploads are in flight on this instance (`Retry-After: 2`). Nothing was stored.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/SupportRetryAfter"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/support/uploads/{uploadId}": {
      "parameters": [
        {
          "name": "uploadId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "get": {
        "operationId": "getSupportUpload",
        "tags": ["SupportTickets"],
        "summary": "One own upload (ARCH-030 \u00a75.13)",
        "description": "Another customer's, an erased or an expired upload is 404 `not_found`.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The upload",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportUpload"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          }
        }
      },
      "delete": {
        "operationId": "deleteSupportUpload",
        "tags": ["SupportTickets"],
        "summary": "Delete an own unattached upload (ARCH-030 \u00a75.13)",
        "description": "The name and the data key are erased at once, the object is deleted. Attached: 409 `upload_in_use`.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          }
        }
      }
    },
    "/api/v1/support/tickets/{ticketId}/files/{fileId}": {
      "get": {
        "operationId": "getSupportTicketFile",
        "tags": ["SupportTickets"],
        "summary": "The bytes of a file of the customer's own ticket (ARCH-030 \u00a75.14)",
        "description": "A file the customer uploaded to this ticket, or a bank attachment of\na message. Served while `scan` is `not_scanned` or `clean`. 10 per\nminute per customer. A file of another ticket or customer is 404.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "ticketId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "fileId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The file. Always `Content-Disposition: attachment;\nfilename*=UTF-8''<name>`, `Content-Security-Policy: sandbox`,\n`X-Content-Type-Options: nosniff`, `Cache-Control: no-store`;\nnever rendered inline.\n",
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "attachment; filename*=UTF-8''<percent-encoded name>"
              },
              "Content-Security-Policy": {
                "schema": {
                  "type": "string",
                  "enum": ["sandbox"]
                }
              },
              "X-Content-Type-Options": {
                "schema": {
                  "type": "string",
                  "enum": ["nosniff"]
                }
              },
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "enum": ["no-store"]
                }
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/jpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "description": "`file_not_ready`: the file is being scanned (only with a scanner; `Retry-After`).",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/SupportRetryAfter"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          },
          "410": {
            "description": "`file_removed`: the file was found infected or erased.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/me": {
      "get": {
        "operationId": "getSupportAgentProfile",
        "tags": ["SupportDesk"],
        "summary": "The signed-in agent's support profile and queues",
        "description": "[P1] Support roles and `mlro`.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Profile",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportAgentProfile"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          }
        }
      },
      "patch": {
        "operationId": "updateSupportAgentProfile",
        "tags": ["SupportDesk"],
        "summary": "Set the display name customers see",
        "description": "[P1] Display name 1 to 40 characters (first name or alias; the bank's choice).",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportAgentProfilePatch"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Profile",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportAgentProfile"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/me/availability": {
      "get": {
        "operationId": "getSupportMyAvailability",
        "tags": ["SupportDesk"],
        "summary": "The signed-in agent's availability",
        "description": "[P1] The roles that work cases: `support_agent`, `support_lead`,\n`sac_officer`, `mlro`, `risk_officer`; `bank_admin` and `auditor`\n403 `forbidden_role` (ARCH-029a \u00a74.16a). No row yet: `offline`,\nsource `self`. A stored `available` whose `last_seen_at` is older\nthan 3 minutes is answered as `offline` with source `expired`\n(derived on read; the row changes with the next write).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Availability",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportAgentAvailability"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      },
      "put": {
        "operationId": "setSupportMyAvailability",
        "tags": ["SupportDesk"],
        "summary": "Set the signed-in agent's availability",
        "description": "[P1] Same roles as GET. `status` `available`, `away` or `offline`;\n`source` `self` (default, the toggle), `idle` (the console went\nidle: away) or `logout` (signed out: offline). Sets `last_seen_at`.\nA change of status writes one row of the presence log (status,\nsource, time; kept 90 days, purged by the daily support retention\nrun), never an audit row. The current state is never used to\nmeasure performance (employee privacy).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportAvailabilityInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Availability",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportAgentAvailability"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/me/heartbeat": {
      "post": {
        "operationId": "supportHeartbeat",
        "tags": ["SupportDesk"],
        "summary": "The desk is open in this console",
        "description": "[P1] Same roles as `GET /me/availability`. Every 60 s while the\ndesk is open. Coalesced: `last_seen_at` is written only when it is\nolder than 30 s; without an availability row nothing is written.\nNever changes the status and writes no audit row. Its own limit (10\nper minute, fails open: a heartbeat that cannot be counted is\ntaken).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "Seen"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/presence": {
      "get": {
        "operationId": "getSupportPresence",
        "tags": ["SupportDesk"],
        "summary": "Team presence and staffing per queue",
        "description": "[P1] `support_lead`, `bank_admin`, `mlro`. The queues the caller\nmay see and the people who work them, with their current state.\nFor every caller but `mlro` the queues worked by `mlro`\n(`compliance`, `kyc`) and the `mlro` users are left out\n(tipping-off). Current state only; no counts over time. Each person\ncarries no `last_seen_at` and `changed_at` only to the minute\n(privacy).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Presence",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportPresence"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/presence/{userId}": {
      "put": {
        "operationId": "setSupportPresence",
        "tags": ["SupportDesk"],
        "summary": "A lead sets an agent away or offline",
        "description": "[P1] `support_lead` only. `status` `away` or `offline` (never\n`available`: 422 `invalid_field`); source `lead`. The target must\nbe a `support_agent` or `support_lead` of the tenant, else 404\n`not_found`. A change writes the presence log and, as an\naccountability event, the audit row\n`support.agent.availability_changed` (from, to, source `lead`; the\nlead as the actor). Answers the team-view object (no\n`last_seen_at`; `changed_at` to the minute).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["status"],
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": ["away", "offline"]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The agent's presence",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportAgentPresence"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/cases": {
      "get": {
        "operationId": "listSupportCases",
        "tags": ["SupportDesk"],
        "summary": "Inbox of support cases",
        "description": "[P1] Cases of the queues the role may see (ARCH-029a \u00a712); a\n`compliance` case only for `mlro` and `auditor`. Without `status`:\nevery status except `closed` and `ai_handling`. `q` searches a\ncase or complaint reference, a customer e-mail, an IBAN or a\ncustomer name (never message bodies, which are encrypted).\nDefault sort `due` (nearest SLA or statutory due first). Cursor\n`q1.`. ETag and 304.\n\nThe AI's conversations (0.32.0): `ai_only=true` lists the chats the\nAI handled alone, never handed to people (no queue, never with a\nperson), in every status unless `status` narrows them.\n`ai_only=true` and `status=ai_handling` are for `support_lead`,\n`sac_officer`, `risk_officer`, `mlro`, `bank_admin` and `auditor`;\n`support_agent` gets 403 `forbidden_role` for either (Core-Bank\nhides both from it). The list keeps the caller's visibility: the\nMLRO sees no AI-only case (\u00a712), so its list is empty. A\n`support_agent` sees no AI-only case anywhere (no list, filter,\nsearch, case view, page, picker or metric) until the case is\nhanded to its queue. A date filter that names a day that does not\nexist (2026-02-31) is 400 `invalid_filter`.\n\nPreviews and AI oversight (helpdesk UX review): every row carries\n`preview`, the newest message with words (author, an excerpt of\nat most 140 characters, time), null for a case under a\ntipping-off lock or in the compliance queue, whoever reads it, and\nfor a case with the silent compliance marker for every role but\n`mlro` and `auditor`.\n`ai_handled=true` lists every chat the AI answered or handed to\npeople (the AI conversations), same roles as `ai_only`; its rows\ncarry `ai` (answers, fixed-text answers, \"Did that help?\", rating,\noutcome, first question). `ai_outcome` and `ai_flagged=true`\nnarrow it and need `ai_handled=true` (else 400 `invalid_filter`).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "queue",
            "in": "query",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "style": "form",
            "explode": true
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/components/schemas/SupportCaseStatus"
              }
            },
            "style": "form",
            "explode": true
          },
          {
            "name": "type",
            "in": "query",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/components/schemas/SupportCaseType"
              }
            },
            "style": "form",
            "explode": true
          },
          {
            "name": "assignee",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "`me`, `none` or a user id."
          },
          {
            "name": "priority",
            "in": "query",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/components/schemas/SupportPriority"
              }
            },
            "style": "form",
            "explode": true
          },
          {
            "name": "language",
            "in": "query",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "style": "form",
            "explode": true
          },
          {
            "name": "sla_state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/components/schemas/SupportSlaState"
              }
            },
            "style": "form",
            "explode": true
          },
          {
            "name": "kind",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/SupportCaseKind"
            },
            "description": "chat or ticket (ARCH-030 \u00a77.4)."
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/components/schemas/SupportTicketCategory"
              }
            },
            "style": "form",
            "explode": true,
            "description": "Ticket category; aml_rfi tickets are seen by mlro and auditor only."
          },
          {
            "name": "initiator",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["customer", "bank"]
            },
            "description": "Who opened the ticket (ARCH-030 \u00a77.4); chat cases have none."
          },
          {
            "name": "requests",
            "in": "query",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": ["to_review", "overdue", "waiting_customer"]
              }
            },
            "style": "form",
            "explode": true,
            "description": "Ticket requests: a submission to review, an open request past its due date, the customer owes an answer (status waiting_customer or an open required request). Several values: any of them."
          },
          {
            "name": "watching",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["me"]
            },
            "description": "Cases the caller watches (ARCH-030 \u00a77.2)."
          },
          {
            "name": "link_kind",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/SupportLinkKind"
            },
            "description": "With `link_id`: every case about that record (ARCH-030 \u00a77.7). `compliance_case` only for `mlro` and `auditor` (else 400 `invalid_filter`)."
          },
          {
            "name": "link_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 128
            },
            "description": "With `link_kind` (one without the other is 400 `invalid_filter`)."
          },
          {
            "name": "created_from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "A date (from its start, UTC) or an RFC 3339 instant."
          },
          {
            "name": "created_to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "A date (to its end, UTC) or an RFC 3339 instant."
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "A date (UTC) or an RFC 3339 instant."
          },
          {
            "name": "statutory_due_within_days",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 31
            },
            "description": "Open complaints and data requests (not resolved or closed) whose statutory due instant is within the days (overdue included): the system view \"Complaints due this week\"."
          },
          {
            "name": "ai_only",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            },
            "description": "`true`: the AI's conversations only (0.32.0; not `support_agent`, 403). `false`: as absent."
          },
          {
            "name": "ai_handled",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            },
            "description": "`true`: every chat the AI answered or handed to people, each row with `ai` (not `support_agent`, 403). `false`: as absent."
          },
          {
            "name": "ai_outcome",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/SupportAiOutcome"
            },
            "description": "With `ai_handled=true` only."
          },
          {
            "name": "ai_flagged",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            },
            "description": "`true`: chats in which the customer answered \"Did that help?\" with no. With `ai_handled=true` only."
          },
          {
            "name": "customer_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 2,
              "maxLength": 100
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["due", "updated", "created"],
              "default": "due"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 512
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "$ref": "#/components/parameters/SupportIfNoneMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of cases",
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/SupportETag"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportCaseList"
                }
              }
            }
          },
          "304": {
            "$ref": "#/components/responses/SupportNotModified"
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      },
      "post": {
        "operationId": "createSupportCase",
        "tags": ["SupportDesk"],
        "summary": "Open a case for a customer (phone, e-mail, letter, in person)",
        "description": "[P1] `support_agent`, `support_lead`, `sac_officer`. Origin\n`agent`; a complaint's statutory clock starts at `received_at`.\nAssigned to the creator when they work the routed queue, else\nqueued. 0.33.0 (one topic, one thread, DEC-0033 decision 34 (i)):\nalways a new chat conversation of the customer, whatever the\ncustomer has open (no 409, nothing read from the customer's open\nchats, so nothing tells of a hidden case); the customer's open-chat\ncap does not apply to staff cases.\n\nWith `kind: \"ticket\"` (ARCH-030 \u00a76.1, `SupportCreateTicketRequest`)\nthe bank opens a ticket: a new conversation and case of kind\n`ticket`, the opening agent message, the requests. Category roles:\n`general` support_agent, support_lead, sac_officer; `kyc` mlro;\n`risk` risk_officer; `aml_rfi` mlro, only from an approved template\nand an open compliance case of this customer (tipping-off lock,\n`compliance` queue); else 403 `forbidden_role`. 409\n`tickets_disabled` (feature off), `letters_unavailable` (a\nconsequential template while letters are not available: no KYC\ndocument store with Object Lock); 503 when the letter of a\nconsequential request cannot be stored (nothing is created); 422\n`template_required`, `template_not_approved`, `locale_missing`,\n`due_date_invalid`, `assignee_not_eligible`, `too_many_requests`,\n`wording_refused` (kyc, risk, aml_rfi: ARCH-030 \u00a712.3, with\n`field` and `note`), `invalid_field`. Audit\n`support.ticket.opened`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/SupportCreateCaseRequest"
                  },
                  {
                    "$ref": "#/components/schemas/SupportCreateTicketRequest"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Case opened",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportCase"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/cases/{caseId}": {
      "get": {
        "operationId": "getSupportCase",
        "tags": ["SupportDesk"],
        "summary": "One case with thread, notes, tasks and events",
        "description": "[P1] Every 200 writes `support.case.viewed` (purpose\n`customer_support`); a 304 writes none. The handoff summary is\nre-identified for the viewer; hold detail only for `mlro`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportCaseId"
          },
          {
            "$ref": "#/components/parameters/SupportMessageLimit"
          },
          {
            "$ref": "#/components/parameters/SupportIfNoneMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "The case",
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/SupportETag"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportCaseDetail"
                }
              }
            }
          },
          "304": {
            "$ref": "#/components/responses/SupportNotModified"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          }
        }
      }
    },
    "/api/v1/support/cases/{caseId}/messages": {
      "get": {
        "operationId": "listSupportCaseMessages",
        "tags": ["SupportDesk"],
        "summary": "Older or newer messages of the case's conversation",
        "description": "[P1] As `GET /support/thread/messages`, staff view: `mlro` and `auditor` get every message of the conversation; every other role the messages of the cases it may see, a case it may not see (tipping-off lock, compliance, a queue without access, ARCH-029a \u00a712) is left out of the page. Audited as a case view on 200.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportCaseId"
          },
          {
            "$ref": "#/components/parameters/SupportBefore"
          },
          {
            "$ref": "#/components/parameters/SupportAfter"
          },
          {
            "$ref": "#/components/parameters/SupportMessageLimit"
          },
          {
            "$ref": "#/components/parameters/SupportIfNoneMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of messages",
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/SupportETag"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportStaffMessagePage"
                }
              }
            }
          },
          "304": {
            "$ref": "#/components/responses/SupportNotModified"
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          }
        }
      },
      "post": {
        "operationId": "replySupportCase",
        "tags": ["SupportDesk"],
        "summary": "Agent reply to the customer",
        "description": "[P1] Only the assignee (403 `not_assignee`). Idempotent on\n`client_message_id`. Meets the first- or next-response clock;\n`await_customer` moves the case to `waiting_customer`. Sends\n`SupportNotify.agent_replied` (e-mail without text, after 60 s,\nskipped when the customer read it). A `resolved` or `closed` case:\n409 `invalid_transition`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportCaseId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportAgentReplyRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Reply stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportStaffMessage"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          }
        }
      }
    },
    "/api/v1/support/cases/{caseId}/notes": {
      "post": {
        "operationId": "addSupportCaseNote",
        "tags": ["SupportDesk"],
        "summary": "Internal note (never shown to the customer)",
        "description": "[P1] Anyone who works the case's queue. Audit `support.note.added`.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportCaseId"
          },
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportNoteRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Note stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportNote"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/cases/{caseId}/tasks": {
      "post": {
        "operationId": "createSupportCaseTask",
        "tags": ["SupportDesk"],
        "summary": "Internal task on a case",
        "description": "[P1] At least one of `queue_code` or `assignee_id`. Anyone who works the case's queue. Audit `support.task.changed`.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportCaseId"
          },
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportTaskRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Task created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportTask"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/cases/{caseId}/tasks/{taskId}": {
      "patch": {
        "operationId": "updateSupportCaseTask",
        "tags": ["SupportDesk"],
        "summary": "Change a task",
        "description": "[P1] A `done` or `cancelled` task cannot be reopened (409 `invalid_transition`).",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportCaseId"
          },
          {
            "name": "taskId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportTaskPatch"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Task",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportTask"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/cases/{caseId}/assign": {
      "post": {
        "operationId": "assignSupportCase",
        "tags": ["SupportDesk"],
        "summary": "Take, assign or release a case",
        "description": "[P1] `\"me\"` takes (409 `already_assigned` when someone else has\nit, unless the caller is a lead of that queue); a user id assigns\n(`support_lead`, `sac_officer` for complaints, `mlro` for\ncompliance; 422 `assignee_not_eligible`); `null` releases (back to\n`queued`). A first assignment writes an `assigned` system message.\nAudit `support.case.assigned`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportCaseId"
          },
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportAssignRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The case",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportCase"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/cases/{caseId}/escalate": {
      "post": {
        "operationId": "escalateSupportCase",
        "tags": ["SupportDesk"],
        "summary": "Move a case to another queue (alias of transfer)",
        "description": "[P1] The alias of `POST /cases/{caseId}/transfer` without\n`assignee_id` (ARCH-030 \u00a70.3 item 6, \u00a77.1; an `assignee_id` is 422\n`invalid_field`): status `escalated`, assignee cleared, reason\nrequired, event `transferred`, audit `support.case.transferred`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportCaseId"
          },
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportEscalateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The case",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportCase"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/cases/{caseId}/transfer": {
      "post": {
        "operationId": "transferSupportCase",
        "tags": ["SupportDesk"],
        "summary": "Transfer a case to another queue (team), optionally to an operator",
        "description": "[P1] ARCH-030 \u00a77.1, chat cases and tickets. Who: the assignee;\nany worker of the source queue while the case is unassigned; the\nsource queue's manager (`support_lead`; `sac_officer` in\n`complaints`; `mlro` in `compliance` and `kyc`; `risk_officer` in\n`risk`); else 403 `forbidden_role`. From `queued`, `assigned`,\n`waiting_customer`, `escalated`, `reopened` (else 409\n`invalid_transition`, also for the same queue). With `assignee_id`\n(an operator of the target queue, 422 `assignee_not_eligible`):\n`assigned`, or `waiting_customer` while the customer owes an\nanswer; without: `escalated`.\n\nInto `compliance` (delegation to compliance) sets\n`tipping_off_lock`: from then on only `mlro` works and `auditor`\nreads the case; the former assignee and every watcher without\naccess lose it (watchers removed, event `watcher_removed` with\n`reason: access` in the hidden period); the reason and the note\nstay in the hidden period (sealed with the event, not a case\nnote); the customer sees nothing change (no message, the same\nticket status and person; ARCH-030 \u00a74.1). Out of `compliance`:\n`mlro` only. A complaint leaves `complaints` only with\n`sac_officer`; an `aml_rfi` ticket stays in `compliance`.\n\nSLA (\u00a77.6): the policy is matched again for the new queue and the\nunmet dues move by the difference of the policies from their\noriginal start, never restarted. Event `transferred`; audit\n`support.case.transferred`; watchers get `SupportNotify.staff_watch`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportCaseId"
          },
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportTransferRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The case as the caller now sees it (no access flags after a move into compliance)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportCase"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/cases/{caseId}/operators": {
      "get": {
        "operationId": "listSupportCaseOperators",
        "tags": ["SupportDesk"],
        "summary": "The people a case may be assigned to (assign by name)",
        "description": "[P1] 0.32.0 (ARCH-029a \u00a74.9a). The active staff users of the cell\nwhose role works the case's queue: exactly the ids\n`POST /cases/{caseId}/assign` accepts (a locked case: MLROs only;\nany active membership row counts), by name, with their role.\nE-mail and current presence (`available`, `away`, `offline`; a\nstale `available` reads `offline`, \u00a74.16a) only for a caller who\nmay assign this case (`can.assign`) or reads the team view\n(`support_lead`, `bank_admin`, `mlro`); for everyone else both are\nnull. A case still with the AI (no queue) has nobody yet: an empty\nlist.\nEvery role that may see the case (else 404); MLRO users only for\n`mlro` and `auditor` (tipping-off, as the team view). Current state\nonly: no history, nothing measured (DEC-0033 decision 32).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportCaseId"
          }
        ],
        "responses": {
          "200": {
            "description": "Operators, by name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportCaseOperatorList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          }
        }
      }
    },
    "/api/v1/support/cases/{caseId}/watchers": {
      "get": {
        "operationId": "listSupportCaseWatchers",
        "tags": ["SupportDesk"],
        "summary": "Watchers (followers) of a case",
        "description": "[P1] ARCH-030 \u00a77.2. The watchers who may see the case. Any role that may see it; an MLRO watcher and a watch added in the hidden period only for `mlro` and `auditor`.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportCaseId"
          }
        ],
        "responses": {
          "200": {
            "description": "Watchers",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportWatcherList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          }
        }
      },
      "post": {
        "operationId": "addSupportCaseWatcher",
        "tags": ["SupportDesk"],
        "summary": "Watch a case, or add a watcher",
        "description": "[P1] ARCH-030 \u00a77.2. `\"me\"`: anyone who may see the case but\n`bank_admin` and `auditor` (403 `forbidden_role`); another user (who\nmay see it and is neither, else 422 `invalid_field`): the assignee\nand the queue's manager (else 403 `forbidden_role`). At most 20 (422\n`too_many_watchers`). Already watching: 200, nothing changes.\nEvent `watcher_added`; no audit row.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportCaseId"
          },
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["user_id"],
                "properties": {
                  "user_id": {
                    "type": "string",
                    "description": "A staff user id or \"me\"."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Watchers",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportWatcherList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/cases/{caseId}/watchers/{userId}": {
      "delete": {
        "operationId": "removeSupportCaseWatcher",
        "tags": ["SupportDesk"],
        "summary": "Stop watching, or remove a watcher",
        "description": "[P1] Oneself (`me` or one's id), or anyone by the assignee and the queue's manager; never `bank_admin` or `auditor` (403). Not watching: 404. Event `watcher_removed`.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportCaseId"
          },
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Watchers",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportWatcherList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          }
        }
      }
    },
    "/api/v1/support/cases/{caseId}/activity": {
      "get": {
        "operationId": "getSupportCaseActivity",
        "tags": ["SupportDesk"],
        "summary": "Activity timeline of a case",
        "description": "[P1] ARCH-030 \u00a77.3. Every message (author, kind, a preview of 140\ncharacters), note, task change, request add, change, submission and\nreview, file, status change, assignment, transfer, watcher change,\nlink, letter, complaint and SLA event, newest first. The hidden\nperiod (tipping-off lock, compliance, the MLRO's work, ARCH-029a\n\u00a74.1) is left out for every role but `mlro` and `auditor`, by the\nsame rules as the case detail. Every 200 writes\n`support.case.viewed` (route `activity`) and clears the viewer's\nunseen marker; a 304 writes none. Cursor `q1.` bound to the case.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportCaseId"
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 512
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "$ref": "#/components/parameters/SupportIfNoneMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of the timeline",
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/SupportETag"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportActivityPage"
                }
              }
            }
          },
          "304": {
            "$ref": "#/components/responses/SupportNotModified"
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          }
        }
      }
    },
    "/api/v1/support/cases/{caseId}/links": {
      "post": {
        "operationId": "addSupportCaseLink",
        "tags": ["SupportDesk"],
        "summary": "Link a record to a case",
        "description": "[P1] ARCH-030 \u00a77.7. Who works the case. A transfer, card, account,\nKYC session or compliance case of the case's customer, or another\ncase of the customer the caller may see (`related_case`, linked\nboth ways); else 422 `invalid_field`. `compliance_case` only by\n`mlro` (403 `forbidden_role`) and seen only by `mlro` and\n`auditor`. 201 the link, 200 when it existed. The ticket's\ncustomer-visible `link` stays the one set at creation. Event\n`linked`; audit `support.case.linked`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportCaseId"
          },
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["kind", "id"],
                "properties": {
                  "kind": {
                    "$ref": "#/components/schemas/SupportLinkKind"
                  },
                  "id": {
                    "type": "string",
                    "maxLength": 128
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The link (it existed)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportCaseLink"
                }
              }
            }
          },
          "201": {
            "description": "The link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportCaseLink"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/cases/{caseId}/links/{linkId}": {
      "delete": {
        "operationId": "removeSupportCaseLink",
        "tags": ["SupportDesk"],
        "summary": "Remove a link",
        "description": "[P1] Who works the case; a compliance case link only `mlro` (others 404). A related case loses the link back. Event `unlinked`; audit `support.case.linked`.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportCaseId"
          },
          {
            "name": "linkId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Removed"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          }
        }
      }
    },
    "/api/v1/support/cases/bulk": {
      "post": {
        "operationId": "bulkSupportCases",
        "tags": ["SupportDesk"],
        "summary": "One action on up to 100 cases",
        "description": "[P1] ARCH-030 \u00a77.5. `assign` (`params.assignee_id`: a user id,\n\"me\" or null), `transfer` (`params` as the transfer body),\n`add_watcher` (`params.user_id`), `set_priority`\n(`params.priority`). Every item is authorised and validated like\nits single route; a case the caller may not see answers\n`not_found` for that item. Invalid input for the whole call is\n422 `invalid_field`. One audit row per changed case (its route's)\nplus `support.bulk.applied` with the counts. 10 per minute per\nstaff user.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportBulkRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "One result per case, in the order given",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportBulkResult"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          }
        }
      }
    },
    "/api/v1/support/customers": {
      "get": {
        "operationId": "searchSupportCustomers",
        "tags": ["SupportDesk"],
        "summary": "Find a customer to open a ticket to",
        "description": "[P1] The customer picker of \"Open a ticket to the customer\"\n(helpdesk UX review): customers of the session's bank whose name or\ne-mail holds `q`, whose IBAN holds it (spaces ignored), or whose\ncustomer number or id is `q`; at most 20, by name. For the roles\nthat open bank tickets (`support_agent`, `support_lead`,\n`sac_officer`, `mlro`, `risk_officer`); others 403\n`forbidden_role`. With tickets off 409 `tickets_disabled`. `q` of 2\nto 100 characters, else 422 `invalid_field`. Never a closure\nreason or a risk field.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 2,
              "maxLength": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Matching customers",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportCustomerMatches"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/customers/{customerId}/transfers": {
      "get": {
        "operationId": "listSupportCustomerTransfers",
        "tags": ["SupportDesk"],
        "summary": "The customer's recent transfers, to pick one for a ticket",
        "description": "[P1] The 20 newest transfers with a leg on the customer's accounts\n(the customer context's rule), for an `operation` value of a\nticket template: date, amount, direction, status, rail and\ncounterparty; no hold or screening detail. Same roles as the\ncustomer search; a customer of another bank, or none, 404. Every\n200 writes one `support.case.viewed` audit row about the customer\n(purpose `customer_support`).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Transfers, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportCustomerTransfers"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/views": {
      "get": {
        "operationId": "listSupportViews",
        "tags": ["SupportDesk"],
        "summary": "Saved inbox views",
        "description": "[P1] ARCH-030 \u00a77.4. The read-only system views (`system:my_open`,\n`system:unassigned`, `system:to_review`,\n`system:overdue_requests`, `system:watching`, `system:due_soon`,\n`system:complaints_due_this_week`), the caller's personal views and\nthe queue views of the queues it works (`read_only` unless it is\nthe queue's manager). `filters` are `GET /cases` parameters.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Views",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["views"],
                  "properties": {
                    "views": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/SupportSavedView"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          }
        }
      },
      "post": {
        "operationId": "createSupportView",
        "tags": ["SupportDesk"],
        "summary": "Save an inbox view",
        "description": "[P1] `personal` (any desk user, 50 each) or `queue` (the queue's\nmanager: `support_lead`, `sac_officer` for `complaints`, `mlro`\nfor `compliance` and `kyc`, `risk_officer` for `risk`; else 403\n`forbidden_role`; 50 per queue). 422 `too_many_views` (with\n`limit`), `invalid_field` (a filter the inbox does not take),\n`queue_not_found`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportSavedViewInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The view",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportSavedView"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/views/{viewId}": {
      "patch": {
        "operationId": "updateSupportView",
        "tags": ["SupportDesk"],
        "summary": "Change a saved view",
        "description": "[P1] The owner of a personal view; a queue view's queue manager (others who work the queue: 403). `name`, `filters`, `sort`, `columns`; `scope` and `queue_code` never change (422). System views: 403.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "viewId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportSavedViewInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The view",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportSavedView"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      },
      "delete": {
        "operationId": "deleteSupportView",
        "tags": ["SupportDesk"],
        "summary": "Delete a saved view",
        "description": "[P1] As PATCH. 204.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "viewId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          }
        }
      }
    },
    "/api/v1/support/cases/{caseId}/status": {
      "post": {
        "operationId": "setSupportCaseStatus",
        "tags": ["SupportDesk"],
        "summary": "Change a case's status (ARCH-029a \u00a78)",
        "description": "[P1] Only the transitions the caller may make (409\n`invalid_transition` with `allowed`). A complaint is resolved only\nby its final reply (409 `complaint_final_reply_required`).\n`resolved` sets `reopen_until`, writes a `resolved` system message,\narms `auto_close` and asks CSAT. Audit\n`support.case.status_changed`.\n\nA ticket (ARCH-030 \u00a76.6) resolves with `resolution` (1 to 1000,\ncustomer-visible; 422 `resolution_required`), optional\n`resolution_code` and `cancel_open_requests`: a submitted request\nis 409 `requests_unreviewed`, a pending or rejected one 409\n`requests_open` unless cancelled now. The resolution is stored\nsealed and written as an agent message of kind `resolution` before\nthe `resolved` system message. Audit `support.ticket.resolved`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportCaseId"
          },
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportStatusRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The case",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportCase"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/cases/{caseId}/classify": {
      "post": {
        "operationId": "classifySupportCase",
        "tags": ["SupportDesk"],
        "summary": "Set type, priority, complaint, flags",
        "description": "[P1] To `complaint`: any support role that may see the case, and\n`mlro`; `complaint_message_id` required (422\n`complaint_message_required`), the clock starts at that message.\nRemoving the complaint type or changing `complaint_scope` after\nregistration: `sac_officer` only, with `reason`. `tipping_off_lock`\nis cleared only by `mlro`. Audit `support.case.classified` (and\n`support.complaint.registered`).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportCaseId"
          },
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportClassifyRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The case",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportCase"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/cases/{caseId}/requests": {
      "post": {
        "operationId": "addSupportTicketRequests",
        "tags": ["SupportDesk"],
        "summary": "Add requests to a ticket (ARCH-030 \u00a76.3)",
        "description": "Assignee only (403 `not_assignee`); not `resolved` or `closed` (409\n`invalid_transition`). 1 to 10 `RequestInput` per call, 20 per\nticket (422 `too_many_requests`); `aml_rfi` only the\n`template_request` form (422 `template_required`); a consequential\ntemplate: one `request_notice` letter for the call, created before\nthe commit (503 and nothing kept when it cannot be stored; 409\n`letters_unavailable` without a KYC store with Object Lock); its\n`letter_issued` notice replaces `ticket_updated`. Effects:\n`pending` requests, `request_added` system messages and events,\n`assigned` -> `waiting_customer`, the optional agent message.\nWording check on kyc, risk, aml_rfi and locked tickets. Audit\n`support.request.added`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportCaseId"
          },
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportAddRequestsRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The new requests",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["requests"],
                  "properties": {
                    "requests": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/SupportStaffRequest"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/cases/{caseId}/requests/{requestId}": {
      "patch": {
        "operationId": "changeSupportTicketRequest",
        "tags": ["SupportDesk"],
        "summary": "Change a request's due date (ARCH-030 \u00a76.4)",
        "description": "Assignee only. A `pending` or `rejected` request (409\n`request_not_open`); the date from tomorrow to 90 days ahead in the\ntenant zone (422 `due_date_invalid`). System message\n`request_due_changed`. A consequential request gets a\n`request_notice_update` letter that supersedes its letter (503 and\nnothing kept when it cannot be stored; 409 `letters_unavailable`\nwithout a KYC store with Object Lock). Audit\n`support.request.changed`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportCaseId"
          },
          {
            "$ref": "#/components/parameters/SupportRequestId"
          },
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["due_date"],
                "properties": {
                  "due_date": {
                    "type": "string",
                    "format": "date"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportStaffRequest"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/cases/{caseId}/requests/{requestId}/cancel": {
      "post": {
        "operationId": "cancelSupportTicketRequest",
        "tags": ["SupportDesk"],
        "summary": "Cancel a request (ARCH-030 \u00a76.3)",
        "description": "Assignee only; a `pending` or `rejected` request (409\n`request_not_open`). `reason` is internal (sealed in the event);\n`customer_note` goes to the customer as an agent message (wording\ncheck on kyc, risk, aml_rfi and locked tickets). System message\n`request_cancelled`. Audit `support.request.cancelled`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportCaseId"
          },
          {
            "$ref": "#/components/parameters/SupportRequestId"
          },
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportCancelRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportStaffRequest"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/cases/{caseId}/requests/{requestId}/review": {
      "post": {
        "operationId": "reviewSupportTicketRequest",
        "tags": ["SupportDesk"],
        "summary": "Accept or reject a submission (ARCH-030 \u00a76.5)",
        "description": "Assignee only; a `submitted` request (409 `request_not_submitted`).\n`reject` needs `reason` (422 `reason_required`), `other` also a\n`note` (customer-visible, wording check on kyc, risk, aml_rfi and\nlocked tickets); the case goes back to `waiting_customer`. System\nmessage `request_accepted` or `request_not_accepted`; event\n`request_reviewed`. With a scanner, a file of the attempt still\n`pending` is 409 `files_scanning`. On `accept` of a ticket of\nretention class `cdd`, every file of the attempt is copied to the\nKYC media store (`<tenant>/<customer>/<kyc_session or\ncdd-requests>/documents/<file_id>-<name>`) and registered before the\ncommit (audit `support.cdd.document_filed`); a storage failure is\n503 and nothing changes. Audit `support.request.reviewed`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportCaseId"
          },
          {
            "$ref": "#/components/parameters/SupportRequestId"
          },
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportReviewRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportStaffRequest"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/cases/{caseId}/cancel": {
      "post": {
        "operationId": "cancelSupportTicket",
        "tags": ["SupportDesk"],
        "summary": "Cancel a ticket (ARCH-030 \u00a76.7)",
        "description": "Tickets only, never a complaint (409 `invalid_transition`). The\nassignee or the queue's manager. Open requests `cancelled`;\n`customer_note` as an agent message; system message\n`ticket_cancelled`; the case `closed` with `close_reason`\n`cancelled`; timers stopped. Audit `support.ticket.cancelled`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportCaseId"
          },
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportCancelRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The case",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportCase"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/cases/{caseId}/close": {
      "post": {
        "operationId": "closeSupportCase",
        "tags": ["SupportDesk"],
        "summary": "Close a case now (ARCH-030 \u00a74.5)",
        "description": "DEC-0033 amendment 2026-10-04. Chat cases and tickets, from any\nstatus but `ai_handling` and `closed` (a `resolved` case skips the\nrest of its reopen window). Never a complaint: 409\n`complaint_final_reply_required` (it ends by the final reply or a\nwithdrawal). The assignee, the queue's manager, or any worker of\nthe queue while the case has no assignee (`can.close`); readers 403\n`forbidden_role`. `reason` is required (422 `reason_required`) and\ncustomer-visible, as a ticket's resolution: the agent message of\nkind `resolution`, then the system message `closed` with\n`params: { \"closed_by\": \"agent\" }` (\"Closed by our team\"); on a\ntipping-off-locked chat case it stays internal. It passes the\nwording check where a resolution does (422 `wording_refused`). A\nticket keeps it as its `resolution` (with `resolution_code`),\ncloses with `close_reason` `resolved` and has the guards of a\nresolve: 409 `requests_unreviewed`, 409 `requests_open` unless\n`cancel_open_requests`. One transaction: the case event `closed`\n(`closed_by` `agent`, the reason sealed with it), every timer\nstopped, audit `support.case.status_changed`; a ticket's\n`ticket_resolved` e-mail and its compliance case's `rfi_closed`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportCaseId"
          },
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportCloseCaseRequest"
              },
              "example": {
                "reason": "The refund reached your account on 3 December."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The case (status `closed`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportCase"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/cases/{caseId}/reopen": {
      "post": {
        "operationId": "reopenSupportCase",
        "tags": ["SupportDesk"],
        "summary": "Reopen a resolved or closed case (ARCH-030 \u00a74.5)",
        "description": "DEC-0033 amendment 2026-10-04. A `resolved` or `closed` case (else\n409 `invalid_transition`) goes to `assigned` with the caller as\nassignee. Any worker of its queue; a complaint only its complaint\nofficer (`sac_officer`, the `mlro` on a locked one), else 403\n`forbidden_role`. Never a withdrawn complaint (409\n`complaint_withdrawn`), never a case whose history was erased or\nanonymised (409 `history_erased`), and a chat case only while its\nconversation has no other open case (409 `open_case_exists`).\n`reason` is required (422 `reason_required`) and internal, sealed\nwith the case event `reopened` (`reopened_by` `agent`). The\ncustomer sees the system message `reopened` with\n`params: { \"reopened_by\": \"agent\" }`. The clocks are re-armed as\nfor a customer reopen; a ticket's close reason is cleared. Audit\n`support.case.status_changed`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportCaseId"
          },
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportReopenCaseRequest"
              },
              "example": {
                "reason": "The customer called; the refund is missing."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The case (status `assigned`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportCase"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/cases/{caseId}/complaint/withdraw": {
      "post": {
        "operationId": "withdrawSupportComplaintOnRequest",
        "tags": ["SupportDesk"],
        "summary": "Record a complaint withdrawal on the customer's written request (ARCH-030 \u00a76.10)",
        "description": "`sac_officer` only; on a tipping-off-locked complaint the `mlro`\n(ARCH-029a \u00a74.17). Every other role: 403 `forbidden_role`. Staff\nnever withdraw a complaint otherwise. `evidence_file_id` is a staff\nupload (`POST /support/desk/uploads?purpose=withdrawal_evidence`) of\nthe customer's written request, required (422\n`written_request_required`, also for an upload of another purpose\nor customer); `channel` `email`, `letter` or `in_person` (a signed\nform); `received_at` not in the future and not before the\ncomplaint's `registered_at` (422 `invalid_field`). Effects of \u00a74.4\nwith `withdrawal_by` `staff_on_written_request` and\n`withdrawn_at` = `received_at`; the evidence is kept with the\ncomplaint (class `complaint`); the confirmation letter is issued to\nthe customer, or later (hourly once letters are available) when it\ncannot be issued now (`complaint.withdrawal_letter` `pending`; the withdrawal\nnever fails over it). 409 `not_withdrawable`,\n`already_final`, `already_withdrawn`. Audit\n`support.complaint.withdrawn`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportCaseId"
          },
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportComplaintWithdrawalRequest"
              },
              "example": {
                "written_request": {
                  "received_at": "2026-12-10T10:12:00.000Z",
                  "channel": "email",
                  "evidence_file_id": "9f8e7d6c-5b4a-4392-8170-6f5e4d3c2b1a"
                },
                "reason": "Customer writes that the issue was solved by the merchant."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The case",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportCase"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/cases/{caseId}/files/{fileId}": {
      "get": {
        "operationId": "getSupportCaseFile",
        "tags": ["SupportDesk"],
        "summary": "The bytes of a file of a case (ARCH-030 \u00a76.8, \u00a78.4)",
        "description": "Any role that may see the case (404 otherwise). Served while `scan`\nis `not_scanned` or `clean`; never inline: Core-Bank shows it only in\nthe sandboxed viewer or as a download with a warning. Every 200\nwrites `support.file.viewed` (purpose `customer_support`, or\n`compliance` for `mlro`). 60 per minute per staff user.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportCaseId"
          },
          {
            "name": "fileId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The file. Always `Content-Disposition: attachment;\nfilename*=UTF-8''<name>`, `Content-Security-Policy: sandbox`,\n`X-Content-Type-Options: nosniff`, `Cache-Control: no-store`;\nnever rendered inline.\n",
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "attachment; filename*=UTF-8''<percent-encoded name>"
              },
              "Content-Security-Policy": {
                "schema": {
                  "type": "string",
                  "enum": ["sandbox"]
                }
              },
              "X-Content-Type-Options": {
                "schema": {
                  "type": "string",
                  "enum": ["nosniff"]
                }
              },
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "enum": ["no-store"]
                }
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/jpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "description": "`file_not_ready`: the file is being scanned (only with a scanner; `Retry-After`).",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/SupportRetryAfter"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          },
          "410": {
            "description": "`file_removed`: the file was found infected or erased.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/desk/uploads": {
      "post": {
        "operationId": "createSupportDeskUpload",
        "tags": ["SupportDesk"],
        "summary": "Staff upload (ARCH-030 \u00a76.11, \u00a78.2)",
        "description": "As `POST /support/uploads` for staff sessions: counsel's written\nsign-off of an aml_rfi template (`purpose=counsel_approval`, by\nmlro or bank_admin only, else 403 `forbidden_role`; kept once an\napproval names it), the written request of a complaint\nwithdrawal (`withdrawal_evidence`), or a ticket file (`ticket`). The\nsame checks, encryption and store; `support_tickets` off: 409\n`tickets_disabled`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Content-Type",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "enum": ["application/pdf", "image/jpeg", "image/png"]
            },
            "description": "Declared type; must agree with the magic bytes (else 422 `file_refused` `type_mismatch`)."
          },
          {
            "name": "Content-Length",
            "in": "header",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 10485760
            },
            "description": "Checked before the body is read (413 `file_too_large`)."
          },
          {
            "name": "X-Client-Upload-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Unique per uploader. A replay with the same SHA-256 answers 200 with the first upload; another SHA-256 is 409 `idempotency_key_reused`."
          },
          {
            "name": "X-File-Name",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 2048
            },
            "description": "UTF-8, percent-encoded. Stored as NFC, last path segment, control and bidi characters removed, at most 120 characters, an extension of the detected type; empty `document.<ext>`."
          },
          {
            "name": "purpose",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["ticket", "withdrawal_evidence", "counsel_approval"],
              "default": "ticket"
            }
          },
          {
            "name": "customer_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The customer the file is about (a customer of the tenant, else 422 `invalid_field`)."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/pdf": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            },
            "image/jpeg": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            },
            "image/png": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportUpload"
                }
              }
            }
          },
          "200": {
            "description": "A replay of the same upload",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportUpload"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_field` (with `field`): a missing or malformed `X-Client-Upload-Id`, `X-File-Name` or `Content-Length` (an empty body, or a body shorter than declared).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "413": {
            "description": "`file_too_large` (with `limit` 10485760), answered on `Content-Length` before the body is read.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          },
          "415": {
            "description": "`unsupported_file_type` (with `allowed`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          },
          "422": {
            "description": "`file_refused` with `note` (`file_refusal`): `type_mismatch`\n(magic bytes, structure, a format hidden inside an image),\n`pdf_encrypted`, `pdf_active_content` (/JavaScript, /JS,\n/Launch, /EmbeddedFile, /RichMedia, /XFA, /OpenAction or /AA with\nan action, also inside object streams; an object stream that\ncannot be checked; more than 50 MB inflated), `image_too_large`\n(over 50 megapixels by the header), `malware` (scanner only).\nNothing is stored for a refused file.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          },
          "503": {
            "description": "`support_unavailable`: no file store, the object store failed, or 8 uploads are in flight on this instance (`Retry-After: 2`). Nothing was stored.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/SupportRetryAfter"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/support/cases/{caseId}/customer-context": {
      "get": {
        "operationId": "getSupportCustomerContext",
        "tags": ["SupportDesk"],
        "summary": "Customer context panel of a case",
        "description": "[P1] Profile, accounts (at most 20) with their available balance\nfrom the ledger (as GET /wallets/{id}/balances resolves it; null\nwhen it cannot be read, never 0), at most 20 recent transactions,\ncards and open holds. Hold reasons and the\ncompliance case id only for `mlro`. Audited as a case view.\n`tickets` (ARCH-030 \u00a76.2): the customer's tickets the caller may\nsee, newest first, at most 20; a hidden ticket (aml_rfi, locked) is\nleft out and never counted.\n`history` (helpdesk UX review): the customer's other chats and\ntickets the caller may see in this bank, newest first, at most 10,\nwith what each was about and how it ended; a locked or\ncompliance-queue case (mlro, auditor) comes without its words\n(`text_hidden`); a case with the silent compliance marker comes\nwithout words and outcome to every role but `mlro` and `auditor`.\nRead in this audited call.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportCaseId"
          }
        ],
        "responses": {
          "200": {
            "description": "Context",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportCustomerContext"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/cases/{caseId}/erase-history": {
      "post": {
        "operationId": "eraseSupportHistory",
        "tags": ["SupportDesk"],
        "summary": "Erase the customer's support bodies (erasure request)",
        "description": "[P1] `support_lead`, on a `data_request` case only (409\n`invalid_transition` otherwise). Deletes message bodies, notes,\nsummaries, CSAT comments, event reasons and task titles of every\ncase of the customer, and the token map and AI traces of a\nconversation no kept case keeps; complaint records and compliance\ncases stay (ARCH-029a \u00a74.14). `complaint_cases_kept` counts the kept\ncomplaints the caller may see. No token-map count (0.23.2: it could\ntell whether a hidden compliance case kept the map). Audit\n`support.retention.anonymised`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportCaseId"
          },
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportEraseRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Counts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportEraseResult"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          }
        }
      }
    },
    "/api/v1/support/dashboard": {
      "get": {
        "operationId": "getSupportDashboard",
        "tags": ["SupportDesk"],
        "summary": "Open cases per queue, breaches, complaints due this week",
        "description": "[P1] Only the queues the role may see. ETag and 304.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportIfNoneMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "Tiles",
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/SupportETag"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportDashboard"
                }
              }
            }
          },
          "304": {
            "$ref": "#/components/responses/SupportNotModified"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          }
        }
      }
    },
    "/api/v1/support/cases/{caseId}/holding-reply": {
      "post": {
        "operationId": "sendSupportHoldingReply",
        "tags": ["SupportDesk"],
        "summary": "Holding reply to a payment-service complaint",
        "description": "[P1] `sac_officer`; on a tipping-off-locked complaint, which the\nSAC officer cannot see, `mlro` (ARCH-029a \u00a74.17).\n`es_payment_services` only, once, before the\n15-business-day date (422 `holding_reply_not_allowed`).\n`final_reply_by` after today and not after `reply_by_latest` (422\n`final_reply_by_too_late`); it becomes the statutory due date.\nIdempotent on `client_message_id`. Audit\n`support.complaint.holding_reply`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportCaseId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportHoldingReplyRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Holding reply stored (kind holding_reply)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportStaffMessage"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/cases/{caseId}/final-reply": {
      "post": {
        "operationId": "sendSupportFinalReply",
        "tags": ["SupportDesk"],
        "summary": "Final written reply to a complaint (resolves it)",
        "description": "[P1] `sac_officer`; on a tipping-off-locked complaint `mlro`\n(ARCH-029a \u00a74.17). Complaints only. The bank appends the tenant's\nescalation text for the customer's language (422\n`escalation_text_missing`). The case becomes `resolved`, the\nregister entry is completed, statutory timers stop,\n`SupportNotify.final_reply_sent`. 409 `already_final`. Idempotent\non `client_message_id`. Audit `support.complaint.final_reply`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportCaseId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportFinalReplyRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Final reply stored (kind final_reply)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportStaffMessage"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/complaints/register": {
      "get": {
        "operationId": "getSupportComplaintRegister",
        "tags": ["SupportDesk"],
        "summary": "Complaint register for a period (JSON or CSV)",
        "description": "[P1] `sac_officer`, `support_lead`, `bank_admin`, `auditor`.\n`from` and `to` are inclusive dates in the tenant zone on\n`registered_at`, at most 366 days (422 `invalid_period`). CSV: at\nmost 20 000 rows (422 `too_many_rows`), RFC 4180, the entry fields\nin order. For `support_lead` and `bank_admin` the complaints of\ntipping-off-locked or compliance-queue cases are left out (rows\nand count; ARCH-029a \u00a75.3). Audit `support.register.exported`.\nRate limit 10 per hour. JSON entries name the customer\n(`customer_name`). `overdue=true` (JSON only; with CSV 422\n`invalid_field`): the complaints past their statutory date, open\nor answered late, never a withdrawn one.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "format",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["json", "csv"],
              "default": "json"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 512
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 200
            }
          },
          {
            "name": "overdue",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            },
            "description": "`true`: only the complaints past their statutory date (JSON only)."
          }
        ],
        "responses": {
          "200": {
            "description": "Register entries",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportRegisterPage"
                }
              },
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          }
        }
      }
    },
    "/api/v1/support/complaints/{caseId}/register-events": {
      "post": {
        "operationId": "addSupportRegisterEvent",
        "tags": ["SupportDesk"],
        "summary": "Append a register event (supervisor escalation, correction)",
        "description": "[P1] `sac_officer`. Append-only; a correction never changes the original row.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportCaseId"
          },
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportRegisterEventRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Event stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportRegisterEvent"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/reports/sac-annual": {
      "get": {
        "operationId": "getSupportSacAnnualReport",
        "tags": ["SupportDesk"],
        "summary": "SAC annual report (computed from the register)",
        "description": "[P1] `sac_officer`, `bank_admin`, `auditor`. For `bank_admin` the figures leave out the complaints of tipping-off-locked or compliance-queue cases (ARCH-029a \u00a75.5). Audit `support.register.exported`.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "year",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 2026
            }
          },
          {
            "name": "format",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["json", "csv"],
              "default": "json"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Report",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportSacAnnualReport"
                }
              },
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "429": {
            "$ref": "#/components/responses/SupportRateLimited"
          }
        }
      }
    },
    "/api/v1/support/queues": {
      "get": {
        "operationId": "listSupportQueues",
        "tags": ["SupportConfig"],
        "summary": "Support queues and routing",
        "description": "[P1] Support roles, `bank_admin`, `auditor` read.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Queues",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["queues"],
                  "properties": {
                    "queues": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/SupportQueue"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          }
        }
      },
      "post": {
        "operationId": "createSupportQueue",
        "tags": ["SupportConfig"],
        "summary": "Add a queue",
        "description": "[P1] `support_lead`, `bank_admin`. Code `^[a-z][a-z0-9_]{1,31}$`, unique per tenant. A queue with the `complaint` case type: `bank_admin` only (403 `forbidden_role`).",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportQueueInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Queue",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportQueue"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/queues/{queueId}": {
      "patch": {
        "operationId": "updateSupportQueue",
        "tags": ["SupportConfig"],
        "summary": "Change a queue",
        "description": "[P1] `support_lead`, `bank_admin`; `sac_officer` for the\n`complaints` queue only. Seeded queues keep their code and stay\nactive; `compliance` keeps work `mlro` and read `auditor`, and\n`complaints` keeps `sac_officer` among its work roles (422\n`invalid_field`). Adding the `complaint` case type to a queue,\ntaking it off one, or changing the `complaints` queue's role lists:\n`sac_officer` and `bank_admin` only (403 `forbidden_role`).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "queueId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportQueueInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Queue",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportQueue"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/queues/{code}/operators": {
      "get": {
        "operationId": "listSupportQueueOperators",
        "tags": ["SupportConfig"],
        "summary": "Operators of a queue (assign pickers)",
        "description": "[P1] ARCH-030 \u00a77.1. Staff users of the cell who work the queue, with the open cases assigned to them that the caller may see. Every role that may see the queue (the compliance queue: `mlro`, `auditor`; else 404).",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Operators",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["operators"],
                  "properties": {
                    "operators": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "user_id",
                          "display_name",
                          "open_assigned"
                        ],
                        "properties": {
                          "user_id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "display_name": {
                            "type": "string"
                          },
                          "open_assigned": {
                            "type": "integer"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          }
        }
      }
    },
    "/api/v1/support/sla-policies": {
      "get": {
        "operationId": "listSupportSlaPolicies",
        "tags": ["SupportConfig"],
        "summary": "SLA policies (business minutes)",
        "description": "[P1] Per queue (ARCH-030 \u00a77.6, `queue_code`, `*` for every queue). Matching, most specific first: (queue, type, priority), (queue, type, *), (queue, *, priority), (queue, *, *), then the same with queue `*`. Read by every support role, `bank_admin` and `auditor`; `mlro` and `risk_officer` 403 (ARCH-030 \u00a713).",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Policies",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["policies"],
                  "properties": {
                    "policies": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/SupportSlaPolicy"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          }
        }
      },
      "post": {
        "operationId": "createSupportSlaPolicy",
        "tags": ["SupportConfig"],
        "summary": "Add an SLA policy",
        "description": "[P1] `bank_admin` any queue; `support_lead` the `*` default and the queues it leads; `sac_officer` the `complaints` queue (ARCH-030 \u00a77.6); else 403. One active policy per queue, type and priority (409). 422 `queue_not_found`. Applies to clocks started after it.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportSlaPolicyInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Policy",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportSlaPolicy"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/sla-policies/{policyId}": {
      "patch": {
        "operationId": "updateSupportSlaPolicy",
        "tags": ["SupportConfig"],
        "summary": "Change an SLA policy",
        "description": "[P1] The editors of its queue (as POST). The queue, type and priority never change (`queue_code` 422). `active: false` deactivates, except the tenant default (`*`, `*`, `*`, 422 `invalid_field`); `active: true` brings a policy back only while no other active policy has its queue, type and priority (409) and its queue is still active (422 `queue_not_found`). Another tenant's policy is 404.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "policyId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportSlaPolicyInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Policy",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportSlaPolicy"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/calendar": {
      "get": {
        "operationId": "getSupportCalendar",
        "tags": ["SupportConfig"],
        "summary": "Tenant business calendar",
        "description": "[P1] Time zone, working days, business hours, holidays. Seeds set\nthe tenant's time zone and the public holidays of its jurisdiction\n(ARCH-029a \u00a76.3).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Calendar",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportCalendar"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          }
        }
      },
      "patch": {
        "operationId": "updateSupportCalendar",
        "tags": ["SupportConfig"],
        "summary": "Change time zone, working days or hours",
        "description": "[P1] `support_lead`, `bank_admin`. The statutory dates of open cases are written in the request; their timers are re-armed after it commits, one case at a time. `time_zone` must be one the clocks compute in (Europe/Madrid, Europe/Zurich, Europe/Berlin, Europe/Vienna, Europe/Paris, Europe/Rome, Europe/Amsterdam, Europe/Brussels, Europe/Luxembourg, Europe/Vaduz, Europe/Lisbon, Atlantic/Canary, Europe/Dublin, Europe/London, UTC), else 422 `invalid_field`. Recomputes the due dates of open cases. A change of `business_hours` or `working_days` also replaces the tenant's default weekly hours (`PUT /hours?queue=tenant`) with that window on those days (0.26.0, ARCH-029a \u00a76.3a); queue hours stay.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportCalendarPatch"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calendar",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportCalendar"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/calendar/holidays": {
      "post": {
        "operationId": "addSupportHoliday",
        "tags": ["SupportConfig"],
        "summary": "Add a regional or tenant holiday",
        "description": "[P1] `support_lead`, `bank_admin`. Recomputes the due dates of open cases.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportHolidayInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Holiday",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportHoliday"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/calendar/holidays/{date}": {
      "delete": {
        "operationId": "deleteSupportHoliday",
        "tags": ["SupportConfig"],
        "summary": "Remove a regional or tenant holiday",
        "description": "[P1] Seeded national holidays cannot be removed (409 `invalid_transition`).",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "date",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Removed"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          }
        }
      }
    },
    "/api/v1/support/hours": {
      "get": {
        "operationId": "getSupportHours",
        "tags": ["SupportConfig"],
        "summary": "Weekly hours of the desk or of one queue",
        "description": "[P1] `queue` names a queue code, or `tenant` (default) for the\ndesk's default. The answer is the effective schedule: the queue's\nown rows, else the tenant's rows, else the calendar's\n`business_hours` on its `working_days` (`source`). Read: every\nrole that reads the configuration (support roles but `mlro`,\n`bank_admin`, `auditor`) and the editors of that queue (`mlro` for\n`compliance` and `kyc`). Unknown queue: 422 `queue_not_found`\n(ARCH-029a \u00a76.3a).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportHoursQueue"
          }
        ],
        "responses": {
          "200": {
            "description": "Hours",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportHours"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      },
      "put": {
        "operationId": "setSupportHours",
        "tags": ["SupportConfig"],
        "summary": "Replace the weekly hours of the desk or of one queue",
        "description": "[P1] Replaces the rows of the scope; `hours: []` removes them (a\nqueue inherits the tenant's hours again, the tenant falls back to\nthe calendar). Split shifts: up to 4 intervals per weekday, not\noverlapping; `to` may be `24:00`. Roles: `support_lead` and\n`bank_admin` for `tenant`, `l1`, `payments`, `cards` and tenant\nqueues; `sac_officer` for `complaints`; `mlro` for `compliance`\nand `kyc`; `risk_officer` for `risk`; else 403 `forbidden_role`.\nThe unmet service-level dues of the open cases of every queue\nwhose schedule changed are moved (the business time left under the\nold schedule is laid onto the new one from now) and re-armed after\nthe commit (\u00a79.5); statutory clocks never move. Audit\n`support.hours.changed`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportHoursQueue"
          },
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportHoursInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Hours",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportHours"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/closures": {
      "get": {
        "operationId": "listSupportClosures",
        "tags": ["SupportConfig"],
        "summary": "Current and upcoming closures",
        "description": "[P1] Closures that have not ended, by start. Read roles as `GET /hours`; `mlro` sees the desk-wide closures and those of `compliance` and `kyc`.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Closures",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["closures"],
                  "properties": {
                    "closures": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/SupportClosure"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      },
      "post": {
        "operationId": "createSupportClosure",
        "tags": ["SupportConfig"],
        "summary": "Close the desk or one queue for a period",
        "description": "[P1] An unplanned closure (team event, outage) of the whole desk\n(`queue` null) or of one queue. `ends_at` after `starts_at` and in\nthe future, at most 92 days long. `reason` is a bank text of 1 to\n200 characters, never shown to customers. Roles as `PUT /hours` for\nthe scope. Service-level dues move as for `PUT /hours`; statutory\nclocks and holidays are untouched. Audit `support.hours.changed`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportClosureInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Closure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportClosure"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/closures/{closureId}": {
      "delete": {
        "operationId": "deleteSupportClosure",
        "tags": ["SupportConfig"],
        "summary": "Remove a closure",
        "description": "[P1] Roles as `PUT /hours` for the closure's scope. Service-level dues move back. Audit `support.hours.changed`.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "closureId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Removed"
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/macros": {
      "get": {
        "operationId": "listSupportMacros",
        "tags": ["SupportConfig"],
        "summary": "Reply macros",
        "description": "[P1] Filter by locale, case type, active.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "locale",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/SupportLocale"
            }
          },
          {
            "name": "case_type",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/SupportCaseType"
            }
          },
          {
            "name": "active",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Macros",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["macros"],
                  "properties": {
                    "macros": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/SupportMacro"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          }
        }
      },
      "post": {
        "operationId": "createSupportMacro",
        "tags": ["SupportConfig"],
        "summary": "Add a macro",
        "description": "[P1] `support_lead`, `bank_admin`.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportMacroInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Macro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportMacro"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/macros/{macroId}": {
      "patch": {
        "operationId": "updateSupportMacro",
        "tags": ["SupportConfig"],
        "summary": "Change a macro (new version)",
        "description": "[P1] `support_lead`, `bank_admin`.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "macroId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportMacroInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Macro",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportMacro"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/help-articles": {
      "get": {
        "operationId": "listSupportHelpArticles",
        "tags": ["SupportConfig"],
        "summary": "Help articles (editor view)",
        "description": "[P2] `support_lead`, `bank_admin` edit; `sac_officer`, `auditor` read.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "locale",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/SupportLocale"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["draft", "published", "archived"]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Articles",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["articles"],
                  "properties": {
                    "articles": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/SupportHelpArticleAdmin"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          }
        }
      },
      "post": {
        "operationId": "createSupportHelpArticle",
        "tags": ["SupportConfig"],
        "summary": "Draft a help article",
        "description": "[P2] Slug unique per tenant and locale (409 `invalid_transition`).",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportHelpArticleInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Draft",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportHelpArticleAdmin"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/help-articles/{articleId}": {
      "patch": {
        "operationId": "updateSupportHelpArticle",
        "tags": ["SupportConfig"],
        "summary": "Edit a help article (a published one gets a new draft version)",
        "description": "[P2] `support_lead`, `bank_admin`.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "articleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportHelpArticleInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Article",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportHelpArticleAdmin"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/help-articles/{articleId}/publish": {
      "post": {
        "operationId": "publishSupportHelpArticle",
        "tags": ["SupportConfig"],
        "summary": "Publish the current draft of an article",
        "description": "[P2] `support_lead`, `bank_admin`. The AI cites only published articles.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "articleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "Published article",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportHelpArticleAdmin"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          }
        }
      }
    },
    "/api/v1/support/request-templates": {
      "get": {
        "operationId": "listSupportRequestTemplates",
        "tags": ["SupportConfig"],
        "summary": "Request templates (ARCH-030 \u00a76.9)",
        "description": "`general` every support role; `kyc`, `risk`, `aml_rfi` only their\neditors, `bank_admin` and `auditor` (a category the role may not\nread: 403 when asked for, else left out). Newest version first.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "category",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/SupportTicketCategory"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/SupportTemplateStatus"
            }
          },
          {
            "name": "locale",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/SupportLocale"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Templates",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["templates"],
                  "properties": {
                    "templates": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/SupportRequestTemplate"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          }
        }
      },
      "post": {
        "operationId": "createSupportRequestTemplate",
        "tags": ["SupportConfig"],
        "summary": "Create a template (draft, version 1)",
        "description": "Editors: `general` support_lead, bank_admin; `kyc` mlro,\nbank_admin; `risk` risk_officer, bank_admin; `aml_rfi` mlro. A code\nis unique per tenant (409 `invalid_transition`; add a version).\nSlots `operation` only for `aml_rfi` and `risk`. A `consequence`\nin any locale makes the template consequential. Audit\n`support.template.changed`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportRequestTemplateInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The draft",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportRequestTemplate"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/request-templates/{templateId}": {
      "get": {
        "operationId": "getSupportRequestTemplate",
        "tags": ["SupportConfig"],
        "summary": "One template with its approvals",
        "description": "A template the role may not read is 404.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportTemplateId"
          }
        ],
        "responses": {
          "200": {
            "description": "The template",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportRequestTemplate"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          }
        }
      },
      "patch": {
        "operationId": "updateSupportRequestTemplate",
        "tags": ["SupportConfig"],
        "summary": "Change a draft",
        "description": "Drafts only (409 `invalid_transition`); editors. Audit `support.template.changed`.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportTemplateId"
          },
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportRequestTemplateInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The template",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportRequestTemplate"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/request-templates/{templateId}/versions": {
      "post": {
        "operationId": "versionSupportRequestTemplate",
        "tags": ["SupportConfig"],
        "summary": "A new draft version",
        "description": "From an approved or archived version; one open (draft or proposed)\nversion per code (409 `invalid_transition`). Editors.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportTemplateId"
          },
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "responses": {
          "201": {
            "description": "The new draft",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportRequestTemplate"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/request-templates/{templateId}/propose": {
      "post": {
        "operationId": "proposeSupportRequestTemplate",
        "tags": ["SupportConfig"],
        "summary": "Propose a draft for approval",
        "description": "Editors. Texts in en, es, de, pt and ar (422 `locale_missing`);\nkyc, risk and aml_rfi texts pass the wording check (422\n`wording_refused`).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportTemplateId"
          },
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "The template",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportRequestTemplate"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/request-templates/{templateId}/approve": {
      "post": {
        "operationId": "approveSupportRequestTemplate",
        "tags": ["SupportConfig"],
        "summary": "Approve a proposed template",
        "description": "Approver per category: `general` an editor (consequential:\nbank_admin); `kyc` mlro or bank_admin; `risk` risk_officer or\nbank_admin; `aml_rfi` mlro (bank_admin when the tenant has one\nMLRO). For kyc, risk, aml_rfi and consequential templates the\nproposer or last editor is 409 `four_eyes_required`. `aml_rfi`\nneeds `counsel_approval` (422 `counsel_approval_required`), dated\non or after this version's proposal (422 `counsel_approval_outdated`),\nwith a sign-off no approval names yet (422 `evidence_in_use`). The\ntexts pass the wording check again (422 `wording_refused`). Both\napprovals are stored, append-only; the approved version archives the\none before it. Audit `support.template.approved` (with the template\nid and version beside counsel's evidence).\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportTemplateId"
          },
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportTemplateApproveRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The template",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportRequestTemplate"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/request-templates/{templateId}/archive": {
      "post": {
        "operationId": "archiveSupportRequestTemplate",
        "tags": ["SupportConfig"],
        "summary": "Archive a template version",
        "description": "Editors. Audit `support.template.changed`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportTemplateId"
          },
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "The template",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportRequestTemplate"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/topics": {
      "get": {
        "operationId": "listSupportTopics",
        "tags": ["SupportConfig"],
        "summary": "Customer ticket topics (ARCH-030 \u00a76.12)",
        "description": "Read by support_agent, support_lead, sac_officer, bank_admin, auditor.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Topics in order",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportTopicList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          }
        }
      }
    },
    "/api/v1/support/topics/{code}": {
      "patch": {
        "operationId": "updateSupportTopic",
        "tags": ["SupportConfig"],
        "summary": "Activate, deactivate or reorder a topic",
        "description": "`support_lead`, `bank_admin`. `complaint` cannot be deactivated\n(422 `invalid_field`). Audit `support.settings.changed`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/SupportTicketTopic"
            }
          },
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "active": {
                    "type": "boolean"
                  },
                  "sort": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 10000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Topics in order",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportTopicList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/settings": {
      "get": {
        "operationId": "getSupportSettings",
        "tags": ["SupportConfig"],
        "summary": "Tenant support settings",
        "description": "[P1] Support roles, `bank_admin`, `auditor` read; `restricted_terms` only for `bank_admin`, `mlro` and `auditor`. Defaults on first read (ARCH-029a \u00a72.2, ARCH-030 \u00a73.2).",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Settings",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportSettings"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          }
        }
      },
      "patch": {
        "operationId": "updateSupportSettings",
        "tags": ["SupportConfig"],
        "summary": "Change support settings",
        "description": "[P1] `bank_admin` and `support_lead` for service fields\n(`reopen_window_days`, `ai_idle_resolve_hours`,\n`show_expected_reply`, `show_availability`, `csat_enabled`,\n`statutory_warning_business_days`); `bank_admin` and `sac_officer`\nfor complaint fields (`complaint_regime`, `tenant_complaint_period`,\n`escalation_texts`, `complaint_retention_days`); `bank_admin` and\n`support_lead` for the ticket fields (`ticket_default_due_days`,\n`ticket_reminder_days`, `customer_open_ticket_limit`);\n`bank_admin` and `mlro` for `restricted_terms` (ARCH-030 \u00a73.2).\nAnother field: 403 `forbidden_role`. Audit\n`support.settings.changed`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportSettings"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Settings",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportSettings"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/settings/ai": {
      "get": {
        "operationId": "getSupportAiSettings",
        "tags": ["SupportConfig"],
        "summary": "AI first-line settings",
        "description": "`support_lead`, `bank_admin`, `auditor` read. `enabled` is the\ntenant feature `support_ai`, switched on by the platform operator\nonly (DEC-0034); models, evaluated locales, the neutral sentences\nand the mandatory triggers are read-only. `policy` is the tenant's\neffective AI policy with both override layers (ARCH-029a \u00a711.5);\n`policy.can.layer` is `bank` for the bank_admin. `models` is null\nper task (the workflows' configuration). `monthly_token_cap` 0: no\ncap; `tokens_used` this calendar month (UTC) from the traces.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "AI settings",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportAiSettings"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          }
        }
      },
      "patch": {
        "operationId": "updateSupportAiSettings",
        "tags": ["SupportConfig"],
        "summary": "Narrow the AI policy (bank layer), cap and extra triggers",
        "description": "`bank_admin`. `monthly_token_cap` (null: as the platform, 0: no AI\nturns),\n`extra_handoff_triggers` (at most 100, phrase 2 to 80 characters)\nand any member of `AiPolicyOverridePatch` (null: as the platform),\nwith an optional `reason`. Written to the `bank` layer of the AI\npolicy (ARCH-029a \u00a711.5): a member that widens the platform policy\nis 422 `policy_widens` with `field`; `kill` is 403\n`kill_switch_platform_only`; `neutral_sentences` is 422\n`invalid_field` (fixed by the platform, tipping-off). Change log and\naudit `ai_policy.override_changed`.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AiPolicyOverridePatch"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "AI settings",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportAiSettings"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          }
        }
      }
    },
    "/api/v1/support/reports/metrics": {
      "get": {
        "operationId": "getSupportMetrics",
        "tags": ["SupportDesk"],
        "summary": "Team metrics of the desk for a window",
        "description": "[P1] 0.32.0 (ARCH-029a \u00a76.8; DEC-0033 decision 32: team level\nonly, no figure per person, no presence). Every support role, over\nthe cases it may see, as the dashboard (\u00a712: a locked or compliance\ncase counts only for `mlro` and `auditor`). Every figure is over the\ncases opened in the window, computed from the tables on every read.\nVolumes by channel (`chat`, `ticket`, `complaint`: one each) and by\nwho opened them (`customer`, `bank`: the bank's requests). `ai`:\nAI-only chats resolved (by the customer's \"Yes\" or the idle timer)\nand cases handed from the AI to people. Times in business minutes\n(`basis: business_hours`) on the queue's service-level hours as they\nare now, from the moment the case reached people (the first handoff,\nelse its creation) to the first agent reply (not the bank's\nrequests) and to the resolution (cases with people); time waiting\nfor the customer is counted. `sla_breaches`: cases with a\nservice-level breach. `csat` and `helpful` (\"Did that help?\") of the\nwindow's cases. Small groups: a median, p90 or CSAT average of 1 to\n4 cases is null and its block says `suppressed: true` (the counts\nstay). A `support_agent` never counts an AI-only chat. 400\n`invalid_date` for a date or instant that does not exist, 400\n`invalid_filter` for `from` not before `to`, a window over 92 days\nor a malformed queue code. The per-period rows of the original\nsketch stay P3.\n",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "A date (from its start, UTC) or an RFC 3339 instant. Default: 30 days before `to`."
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "A date (to its end, UTC) or an RFC 3339 instant. Default: now. At most 92 days after `from`."
          },
          {
            "name": "queue",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "One queue code (the AI-only chats have none); a queue the caller may not see is 404."
          }
        ],
        "responses": {
          "200": {
            "description": "Metrics",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportMetrics"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/SupportBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/SupportUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          }
        }
      }
    },
    "/api/v1/support/internal/turns/{messageId}": {
      "get": {
        "operationId": "getSupportTurnContext",
        "tags": ["SupportInternal"],
        "summary": "Context of one AI turn (Assistant.support_turn)",
        "description": "[P2] Pending customer messages, the 12 before them, known entities\n(layer 1 of the gateway), case flags, AI settings for the turn,\nthe client's actions and the existing tokens. 409 `turn_done` when\nthe turn already has an AI message or a handoff, or a later turn\nanswered its messages.\n",
        "security": [
          {
            "ServiceKeyAuth": [],
            "SupportInternalKeyAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportServiceTenant"
          },
          {
            "name": "messageId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Turn context",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportTurnContext"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/internal/token-maps": {
      "post": {
        "operationId": "tokeniseSupportValues",
        "tags": ["SupportInternal"],
        "summary": "Assign or look up PII tokens of a conversation",
        "description": "[P2] Deterministic per conversation (keyed hash of the normalised\nvalue); values, refs and labels stored encrypted. 1 to 200 entries;\nat most 2000 tokens per conversation (422 `token_map_full`).\n",
        "security": [
          {
            "ServiceKeyAuth": [],
            "SupportInternalKeyAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportServiceTenant"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportTokeniseRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Tokens in the order of the entries",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportTokeniseResult"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/internal/token-maps/{conversationId}": {
      "get": {
        "operationId": "listSupportTokens",
        "tags": ["SupportInternal"],
        "summary": "Tokens of a conversation (never values)",
        "description": "[P2] For the output check: only known tokens may appear in model output.",
        "security": [
          {
            "ServiceKeyAuth": [],
            "SupportInternalKeyAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportServiceTenant"
          },
          {
            "name": "conversationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Tokens",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportTokenList"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          }
        }
      }
    },
    "/api/v1/support/internal/traces": {
      "post": {
        "operationId": "createSupportTrace",
        "tags": ["SupportInternal"],
        "summary": "Store a tokenised AI trace (prompt, completion, tool, moderation)",
        "description": "[P2] Idempotent on (turn_id, kind, seq): a repeat with the same\npayload (same SHA-256) answers 200 with the first result; another\npayload under the same key is 409 `trace_conflict`. 422\n`raw_pii_detected` for a mod-97 IBAN, a Luhn-valid PAN or an e-mail\naddress (format characters skipped, groups split by white space,\ndots, hyphens or slashes read as one). Encrypted; deleted after 90\ndays.\n",
        "security": [
          {
            "ServiceKeyAuth": [],
            "SupportInternalKeyAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportServiceTenant"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportTraceInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Already stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportTraceCreated"
                }
              }
            }
          },
          "201": {
            "description": "Stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportTraceCreated"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/internal/traces/{traceId}": {
      "get": {
        "operationId": "getSupportTrace",
        "tags": ["SupportInternal"],
        "summary": "Read a trace by id (replay)",
        "description": "[P2] Tokenised payload and its hash.",
        "security": [
          {
            "ServiceKeyAuth": [],
            "SupportInternalKeyAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportServiceTenant"
          },
          {
            "name": "traceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Trace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportTrace"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          }
        }
      }
    },
    "/api/v1/support/internal/tools/{tool}": {
      "post": {
        "operationId": "runSupportTool",
        "tags": ["SupportInternal"],
        "summary": "Run one read-only AI tool for a turn",
        "description": "[P2] Arguments validated against the tool's input schema\n(`SupportTool*Input`); tokens resolved to the customer's own\nrecords; read with the customer's scope and RLS; the result\ntokenised with the conversation's map and capped at 8 KB\n(`SupportTool*Output`). Tool errors are in `error`, not the\nstatus. At most 4 calls per turn (409 `tool_budget_exhausted`).\nAI policy (ARCH-029a \u00a711.5, DEC-0034): a tool the tenant's effective\npolicy does not list is 403 `tool_not_allowed`, any tool while a kill\nswitch is set 403 `policy_kill`; nothing is read or traced.\n",
        "security": [
          {
            "ServiceKeyAuth": [],
            "SupportInternalKeyAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportServiceTenant"
          },
          {
            "name": "tool",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "account_balances",
                "spending_summary",
                "recent_transactions",
                "transaction_detail",
                "card_status",
                "fees_explained",
                "statement_link",
                "search_help"
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportToolCallRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Tool result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportToolResult"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/internal/ai-messages": {
      "post": {
        "operationId": "storeSupportAiMessage",
        "tags": ["SupportInternal"],
        "summary": "Store the AI answer of a turn",
        "description": "[P2] Checks: open turn (409 `turn_done`; a repeat of the same turn\nanswers 200 with the stored id), a model answer on a turn that runs\ntemplates only (`ai.templates_only` of the turn context, ARCH-029a\n\u00a72.1, \u00a72.3: 409 `templates_only`, nothing stored; the workflows fall\nback to the template), known tokens (422\n`unknown_token`), no raw IBAN, PAN or e-mail (422\n`raw_pii_detected`), allow-listed actions the client declared (422\n`action_not_allowed`), resolvable citations and at least one for an\nanswer (422 `unknown_citation`), moderation passed. The scope and\nwording rules of the workflows run again here and no verdict of the\ncaller is trusted (ARCH-029a \u00a711.1a): AML, sanctions or suspicion\nwording (422 `aml_topic`), a refusal whose body is not the fixed\nsentence of its `refusal_reason` (422 `refusal_not_template`), a\nclarify that is not one question sentence of at most 200\ncharacters without digits outside tokens, code, Markdown, links or\nAML, advice, off-topic or other-person terms (422\n`clarify_not_allowed`), a `presence` clarify that is not the fixed\npresence sentence (422 `presence_not_template`), a code fence, or inline code in a clarify\n(422 `code_block`), a request for a credential (422\n`credential_request`), an instruction to pay or transfer (422\n`payment_instruction`), a control, bidi or zero-width character (422\n`control_characters`), a link (bare hosts and IDN included) to a\nhost outside `SUPPORT_LINK_HOSTS` (422 `link_not_allowed`). Then\nre-identifies body and action params and stores the message with\n`ai_generated: true` and the prompt it names: `prompt_version` and\nthe first 12 characters of `prompt_hash`\n(`support-2026-10-04.1.c17cda3bcfb2`); a message without a version\n(older workflows) gets the server's constant.\n",
        "security": [
          {
            "ServiceKeyAuth": [],
            "SupportInternalKeyAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportServiceTenant"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportAiMessageInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Already stored for this turn",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportAiMessageCreated"
                }
              }
            }
          },
          "201": {
            "description": "Stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportAiMessageCreated"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/internal/handoffs": {
      "post": {
        "operationId": "createSupportHandoff",
        "tags": ["SupportInternal"],
        "summary": "Hand a turn to a person (rule, model or system)",
        "description": "[P2] Sets type, queue, priority and flags (ARCH-029a \u00a711.4),\nregisters a complaint from `complaint_message_id`, sets\n`tipping_off_lock` and the compliance queue for\n`restricted_topic` (with the neutral sentence when\n`neutral_reply`), stores the summary tokenised, arms the clocks,\nwrites the system messages and `support.ai.handoff`. A repeat of the\nsame turn answers 200 with the first result.\n",
        "security": [
          {
            "ServiceKeyAuth": [],
            "SupportInternalKeyAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportServiceTenant"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportInternalHandoffInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Already handed off for this turn",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportInternalHandoffResult"
                }
              }
            }
          },
          "201": {
            "description": "Handed off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportInternalHandoffResult"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "409": {
            "$ref": "#/components/responses/SupportConflict"
          },
          "422": {
            "$ref": "#/components/responses/SupportUnprocessable"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/internal/timers": {
      "post": {
        "operationId": "fireSupportTimer",
        "tags": ["SupportInternal"],
        "summary": "A case timer fired (SupportCase.timer_fired)",
        "description": "[P1] Stale epoch, closed case or met clock: `applied: false`.\nOtherwise breach or warning events and alerts, the AI turn\ndeadline, AI idle resolution or auto close (ARCH-029a \u00a77.7). 409\n`request_in_progress`: the epoch is not committed (yet, or ever:\na rolled-back request); SupportCase does not retry it, the daily\nreconcile marks a due it missed.\n\nTickets (ARCH-030 \u00a710.2): `request_reminder` sends one reminder\ne-mail while a request of the ticket is still pending or rejected\n(a submitted, cancelled or re-dated request, a reminder more than\n12 h late, or one already sent: `already_met`); `request_due`\nwrites one `request_overdue` event and one `sla_alert` per open\nrequest past its due date and changes no status. Either re-arms\nthe case with the next request timer.\n",
        "security": [
          {
            "ServiceKeyAuth": [],
            "SupportInternalKeyAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportServiceTenant"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportTimerFired"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Applied or ignored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportTimerResult"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/internal/reconcile": {
      "post": {
        "operationId": "reconcileSupportTimers",
        "tags": ["SupportInternal"],
        "summary": "Daily timer reconciliation over every tenant",
        "description": "[P1] No `X-Tenant-ID`: each tenant in its own RLS scope. Marks due\ndates that passed without a timer and re-arms every open case with\na new epoch: every open case, paged by id, each case in a\ntransaction of its own. Ticket request timers are re-armed with the\ncase timers (ARCH-030 \u00a711); a passed request due date is marked\noverdue once; a passed reminder is not sent late. Then, when letters\nare available, the complaint withdrawal letters left pending are\nissued (oldest first, each in a transaction of its own, at most one\nper withdrawal); a letter that still fails is counted in\n`letters_failed` and never fails the run.\n",
        "security": [
          {
            "ServiceKeyAuth": [],
            "SupportInternalKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Counts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportReconcileResult"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/internal/retention": {
      "post": {
        "operationId": "runSupportRetention",
        "tags": ["SupportInternal"],
        "summary": "Daily retention over every tenant",
        "description": "[P1] Anonymises non-complaint cases closed more than 3 years ago\n(task titles become a placeholder), skips complaints while no\nretention is set and compliance cases always (AML record keeping),\ndeletes AI traces older than 90 days, seeds next year's national\nholidays from 1 December once per year. Idempotent and resumable;\none audit row per tenant.\n",
        "security": [
          {
            "ServiceKeyAuth": [],
            "SupportInternalKeyAuth": []
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportRetentionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Counts per tenant",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportRetentionResult"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "503": {
            "$ref": "#/components/responses/SupportUnavailable"
          }
        }
      }
    },
    "/api/v1/support/internal/notify-context/{eventId}": {
      "get": {
        "operationId": "getSupportNotifyContext",
        "tags": ["SupportInternal"],
        "summary": "What SupportNotify needs to send one e-mail",
        "description": "[P1] Recipient, locale, brand and links; never message text, an\namount or a case type. `skip` when the customer read the thread\npast the event or `support_chat` is off.\n\nTickets (ARCH-030 \u00a710.3): `ticket_opened`, `ticket_updated`,\n`request_not_accepted`, `ticket_resolved`, `letter_issued` and\n`complaint_withdrawn` take the message the notice is about;\n`request_reminder` takes the case id; `staff_watch` a case event or\na customer message. Ticket links are\n`<scheme>://support/tickets/<case_id>?customer_id=<id>` and\n`<portal>/help/requests/<case_id>`; letters\n`<scheme>://documents/letters/<letter_id>?customer_id=<id>` and\n`<portal>/documents`. Never a subject, request title, document\ntype, amount, category or text: a kyc and an aml_rfi ticket give the\nsame answer apart from customer, address and links. A ticket notice\nskips when the customer read the ticket past it or\n`support_tickets` is off; `letter_issued` and `complaint_withdrawn`\nnever skip while there is an address.\n",
        "security": [
          {
            "ServiceKeyAuth": [],
            "SupportInternalKeyAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/SupportServiceTenant"
          },
          {
            "name": "eventId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "kind",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/SupportNotifyKind"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Notify context",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportNotifyContext"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/SupportForbidden"
          },
          "404": {
            "$ref": "#/components/responses/SupportNotFound"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Bearer token obtained via admin login (`POST /api/v1/auth/login`) or\nOAuth2 Client Credentials grant (`POST /oauth/token`). Admin tokens\ncarry RBAC role claims; OAuth2 tokens carry tenant scope and permission\nclaims. Tokens are validated on every request; expired or revoked tokens\nreturn `401 Unauthorized`.\n"
      },
      "BasicAuth": {
        "type": "http",
        "scheme": "basic",
        "description": "HTTP Basic Auth for card network inbound endpoints (JIT gateway and webhooks).\nCredentials are configured per-endpoint via environment variables.\nBase64-encoded `username:password` in the Authorization header.\n"
      },
      "ServiceKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Service-Key",
        "description": "Internal service-to-service authentication key. Used by the\nworkflow automation service to call internal API endpoints\n(KYB status updates, circuit breaker transitions). Never use in\nexternal API consumer code.\n"
      },
      "SupportInternalKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Support-Internal-Key",
        "description": "Second key of `/api/v1/support/internal/*` (ARCH-029a \u00a77.0, AI\ngovernance P0), held by the workflows service only\n(`SUPPORT_INTERNAL_KEY`, compared in constant time). Sent together\nwith `X-Service-Key`. While the server has no `SUPPORT_INTERNAL_KEY`\n(one release of transition) the shared key alone passes.\n"
      }
    },
    "parameters": {
      "ChangeReason": {
        "name": "X-Change-Reason",
        "in": "header",
        "required": false,
        "description": "The platform operator's reason for a change made on a bank's behalf\n(10 to 1000 characters, percent-encoded UTF-8; see \"Platform assist\"\nin the introduction). Required for a `super_admin` in the platform\nscope on every bank-settings write; ignored for bank staff.\n",
        "schema": {
          "type": "string",
          "maxLength": 12000
        }
      },
      "SafeguardingTenant": {
        "name": "X-Tenant-ID",
        "in": "header",
        "required": true,
        "description": "Tenant whose safeguarding data is read or changed (required).",
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "ScaToken": {
        "name": "X-SCA-Token",
        "in": "header",
        "required": false,
        "schema": {
          "type": "string"
        },
        "description": "BR-FM-010. Strong customer authentication for card and card-rule\nwrites, the PAN reveal and the card request, for customer JWT\ncallers (0.34.0): the same gate as `POST /api/v1/transfers` with\n`kind` `card_action` and no exemptions. The SCA authentication code\nfrom identity-api, or, while the tenant's mode allows it, the\ncaller's own access token. Answers as there: 403 `SCA required`\n(`code` `sca_required` with the challenge, `sca_setup_required`, or\n`sca_device_locked` with `reason` and `until`),\n403 `Invalid SCA token` with its `code`, 409 `sca_busy`, 429\n`sca_rate_limited`, 503 `sca_unavailable`. The intent hashes\n`FERNEL-CARD-INTENT-V1`, `tenant:<uuid>`, `customer:<uuid>`,\n`card:<card uuid, or - for the card request and card rules>`, for\na rule update or delete `rule:<rule uuid>` (SPEC-sca-canonical-v1\n1.3.0), `action:<status|limits|label|account|rule|suspend|terminate|sensitive,\nor request|rule_create|rule_update|rule_delete>` (a card rule's\nmethod and id are bound) and `body:<lower-case hex\nSHA-256 of the raw request body, or - without one>`, joined by\n`\\n`: send the same body bytes again with the code. A code is\nspent once: only the card request (which enforces its\n`Idempotency-Key`) takes it again as the retry of the same write;\nevery other card and card-rule write answers 403 `sca_token_used`.\nService-key (workflow) and MFA-verified admin session callers do\nnot send it.\n"
      },
      "TenantId": {
        "name": "tenantId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        }
      },
      "WoffPeriodFrom": {
        "name": "from",
        "in": "query",
        "required": false,
        "description": "First business day of the period (write-off date in the bank's time zone), inclusive.",
        "schema": {
          "type": "string",
          "format": "date"
        }
      },
      "WoffPeriodTo": {
        "name": "to",
        "in": "query",
        "required": false,
        "description": "Last business day of the period, inclusive.",
        "schema": {
          "type": "string",
          "format": "date"
        }
      },
      "CustomerId": {
        "name": "customerId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        }
      },
      "BeneficiaryId": {
        "name": "beneficiaryId",
        "in": "path",
        "required": true,
        "description": "Beneficiary UUID. A malformed value returns 400 `invalid_id`.",
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "AccountId": {
        "name": "accountId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        },
        "description": "Numeric registry ID or hex ledger ID"
      },
      "WalletId": {
        "name": "walletId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        }
      },
      "SupportTransferCase": {
        "name": "case_id",
        "in": "query",
        "required": false,
        "description": "Required for the support roles (support_agent, support_lead,\nsac_officer): a case the caller can see; the\ntransfer must be its linked transfer or in its customer context\n(ARCH-029a \u00a712). Ignored for other callers.\n",
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "TransferId": {
        "name": "transferId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        }
      },
      "AcceptLanguage": {
        "name": "Accept-Language",
        "in": "header",
        "required": false,
        "schema": {
          "type": "string",
          "example": "ar"
        },
        "description": "BCP-47 language tag for response localisation. Controls the language\nof system-generated `description` fields on transfer objects.\nSupported: `en` (default), `ar`, `de`, `fr`, `es`, `tr`, `ru`.\nUnknown or missing tags fall back to `en`.\n"
      },
      "HoldId": {
        "name": "holdId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        }
      },
      "CardId": {
        "name": "cardId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        }
      },
      "CredentialId": {
        "name": "credentialId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        }
      },
      "LimitId": {
        "name": "limitId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        }
      },
      "MemberId": {
        "name": "memberId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        }
      },
      "StatementId": {
        "name": "statementId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "format": "uuid"
        },
        "description": "Bank statement UUID"
      },
      "EntryId": {
        "name": "entryId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "format": "uuid"
        },
        "description": "Statement entry UUID"
      },
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": true,
        "schema": {
          "type": "string",
          "format": "uuid"
        },
        "description": "Unique key for idempotent requests"
      },
      "TenantScope": {
        "name": "X-Tenant-ID",
        "in": "header",
        "schema": {
          "type": "string"
        },
        "description": "Tenant scope (injected by ForwardAuth or set manually)"
      },
      "HistoryLimit": {
        "name": "limit",
        "in": "query",
        "required": false,
        "schema": {
          "type": "integer",
          "minimum": 1,
          "default": 50
        },
        "description": "Rows per page, 1 to 200 (larger values are clamped to 200). Not a\npositive integer: 400 `invalid_limit`. Compatibility window\n(DEC-0029): a request without `cursor` may still ask for up to\n500 until the customer portal pages with `next_cursor`\n(SF-portal-history-cursor); then the clamp is 200 for every\nrequest.\n"
      },
      "HistoryCursor": {
        "name": "cursor",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string",
          "maxLength": 512
        },
        "description": "`next_cursor` of the previous page, sent with the same filters.\nOpaque (`c1.` prefix). A cursor issued for other filters, another\nendpoint or another path id, or one that does not decode, is 400\n`invalid_cursor`. Compatibility: a value without the prefix that\nparses as an ISO 8601 timestamp (e.g. the `created_at` of the last\nrow) returns the rows strictly older than it, as before; rows that\nshare that timestamp can be skipped. The response then carries a\n`c1.` cursor.\n"
      },
      "HistoryAccountId": {
        "name": "account_id",
        "in": "query",
        "required": false,
        "schema": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "maxItems": 10
        },
        "style": "form",
        "explode": true,
        "description": "Ledger account id(s) (hex, case and leading zeros ignored). On the\ncustomer list, repeatable up to 10 times: only those of the\ncustomer's own accounts are listed (a customer caller naming an\naccount that is not theirs is refused by the scope check). On the\naccount list at most one; another account gives an empty list.\n"
      },
      "HistoryDirection": {
        "name": "direction",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string",
          "enum": ["in", "out"]
        },
        "description": "From the listed accounts' point of view. A transfer between two\nlisted accounts is `out`.\n"
      },
      "HistoryFrom": {
        "name": "from",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string",
          "format": "date"
        },
        "description": "First day (inclusive) of `created_at`, in the caller's time zone\n(`tz_offset_minutes`, default UTC). 1970-01-02 to 9999-12-30.\n"
      },
      "HistoryTo": {
        "name": "to",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string",
          "format": "date"
        },
        "description": "Last day (inclusive) of `created_at`, in the caller's time zone.\nBefore `from` is 400 `invalid_filter`.\n"
      },
      "HistoryTzOffset": {
        "name": "tz_offset_minutes",
        "in": "query",
        "required": false,
        "schema": {
          "type": "integer",
          "minimum": -840,
          "maximum": 840,
          "default": 0
        },
        "description": "Minutes east of UTC (local time = UTC + offset, as on the insights\nendpoints). Shifts the `from` / `to` day bounds to local midnight.\nPart of the cursor's filter set.\n"
      },
      "HistoryStatus": {
        "name": "status",
        "in": "query",
        "required": false,
        "schema": {
          "type": "array",
          "maxItems": 6,
          "items": {
            "type": "string",
            "enum": [
              "completed",
              "pending",
              "failed",
              "cancelled",
              "voided",
              "returned",
              "rejected",
              "authorized",
              "settled",
              "reversed",
              "declined",
              "expired",
              "disputed"
            ]
          }
        },
        "style": "form",
        "explode": true,
        "description": "Repeatable up to 6 times; a row matches any of them (DEC-0030).\nTransfer lists: completed, pending, failed, cancelled, voided,\nreturned, rejected. `cancelled` also matches `voided`, `failed` also\n`rejected`, and `returned` also a transfer an R-transaction returned\n(return, refund, reversal) or that was returned within its holding\nperiod; the others are exact. Card list: authorized, settled,\nreversed, declined, expired, disputed. Any other value is 400\n`invalid_filter`. Order and repeats do not change the cursor's filter\nset.\n"
      },
      "HistoryCurrency": {
        "name": "currency",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string",
          "pattern": "^[A-Za-z]{3}$"
        },
        "description": "ISO 4217 alpha code, any case."
      },
      "HistoryEventType": {
        "name": "event_type",
        "in": "query",
        "required": false,
        "schema": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "maxItems": 20
        },
        "style": "form",
        "explode": true,
        "description": "Transfer event type(s), repeatable up to 20 times."
      },
      "HistoryQuery": {
        "name": "q",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string",
          "minLength": 2,
          "maxLength": 100
        },
        "description": "Text search, 2 to 100 characters after trimming, case-insensitive\nsubstring (`%` and `_` match literally). Transfers: description,\nreference, counterparty name, destination (payee) name and the\npayer names recorded in metadata (`sender_name`, `debtor_name`,\n`counterparty`): the fields `from_name` / `to_name` are built from.\nCard authorisations: merchant name. A search runs with a 3 s\nstatement timeout; hitting it is 422 `search_too_broad`. At most 2\nsearches of one customer run at once; more is 429 `search_busy`.\n"
      },
      "HistoryAmountMin": {
        "name": "amount_min",
        "in": "query",
        "required": false,
        "schema": {
          "type": "integer",
          "format": "int64",
          "minimum": 0
        },
        "description": "Smallest absolute amount in minor units, inclusive (DEC-0030).\nDigits only; above `amount_max` is 400 `invalid_filter`. Part of the\ncursor's filter set when given.\n"
      },
      "HistoryAmountMax": {
        "name": "amount_max",
        "in": "query",
        "required": false,
        "schema": {
          "type": "integer",
          "format": "int64",
          "minimum": 0
        },
        "description": "Largest absolute amount in minor units, inclusive (DEC-0030). Part\nof the cursor's filter set when given.\n"
      },
      "HistoryQueryType": {
        "name": "q_type",
        "in": "query",
        "required": false,
        "schema": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "maxItems": 20
        },
        "style": "form",
        "explode": true,
        "description": "Event type(s) that also match `q`, repeatable up to 20 times. With\n`q`, a transfer matches when its text matches `q` OR its event type\nis one of these (a localised title such as \"Aufladung\" stands for an\nevent type). Without `q` it is ignored. `event_type` stays an AND\nfilter. Part of the cursor's filter set. Card list: 400\n`invalid_filter`.\n"
      },
      "StatementAccountId": {
        "name": "account_id",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string",
          "pattern": "^[A-Za-z0-9]{1,64}$"
        },
        "style": "form",
        "explode": true,
        "description": "Ledger account id (as in the history). Required and single for\n`pdf`, `camt053` and `mt940`; for `csv` and the summary up to 10\n(repeat the parameter), absent = all the customer's accounts.\n"
      },
      "StatementFrom": {
        "name": "from",
        "in": "query",
        "required": true,
        "schema": {
          "type": "string",
          "format": "date"
        },
        "description": "First day (inclusive, local day by `tz_offset_minutes`)."
      },
      "StatementTo": {
        "name": "to",
        "in": "query",
        "required": true,
        "schema": {
          "type": "string",
          "format": "date"
        },
        "description": "Last day (inclusive). Not after today; at most 366 days after\n`from` inclusive, else `422 invalid_period`.\n"
      },
      "StatementInterval": {
        "name": "interval",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string",
          "enum": ["week"]
        },
        "description": "Summary only. `week`: also return `periods`, one per ISO week\n(Monday to Sunday, local days by `tz_offset_minutes`) of the period,\nat most 13 (more: `422 invalid_period`). Other values: `400\ninvalid_filter`. Absent: no `periods`.\n"
      },
      "StatementFormat": {
        "name": "format",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string",
          "enum": ["pdf", "csv", "camt053", "mt940"],
          "default": "pdf"
        },
        "description": "`xlsx` and other values: `422 unsupported_format`."
      },
      "ExportFormat": {
        "name": "format",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string",
          "enum": ["csv", "pdf"],
          "default": "csv"
        },
        "description": "`xlsx` and other values: `422 unsupported_format`."
      },
      "DocumentLocale": {
        "name": "locale",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string",
          "enum": ["en", "de", "es", "pt", "ar"],
          "default": "en"
        },
        "description": "Document language (formal register). `ar` renders the English\ndocument (Latin fonts only in this version); a region suffix\n(`pt-BR`, `de-CH`) is accepted. Dates: de `dd.MM.yyyy`, es and pt\n`dd/MM/yyyy`, en `d MMM yyyy`. Amounts: en `1,234.56`; de, es, pt\n`1.234,56`; a Swiss tenant `1\u2019234.56`.\n"
      },
      "SupportRequestId": {
        "name": "requestId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "SupportTemplateId": {
        "name": "templateId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "SupportCaseId": {
        "name": "caseId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "format": "uuid"
        },
        "description": "Support case id. A case of another tenant, or one the role may not see, is 404 `not_found`."
      },
      "SupportThreadId": {
        "name": "threadId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "format": "uuid"
        },
        "description": "The thread (a chat case of the customer, `thread_id` of `GET /conversations`). A request (ticket), another customer's case or an unknown id is 404 `not_found`; not a UUID is 400 `invalid_id`."
      },
      "SupportIfNoneMatch": {
        "name": "If-None-Match",
        "in": "header",
        "required": false,
        "schema": {
          "type": "string"
        },
        "description": "The ETag of the last answer; equal to the current one answers 304 with no body (ARCH-029a \u00a70.7)."
      },
      "SupportMessageLimit": {
        "name": "limit",
        "in": "query",
        "required": false,
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100,
          "default": 30
        },
        "description": "Messages per page; above 100 is clamped; not a positive integer is 400 `invalid_limit`."
      },
      "SupportBefore": {
        "name": "before",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string",
          "maxLength": 512
        },
        "description": "`m1.` cursor (`next_cursor`): messages older than it. Not together with `after`."
      },
      "SupportAfter": {
        "name": "after",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string",
          "maxLength": 512
        },
        "description": "`m1.` cursor (`latest_cursor`): messages newer than it. Not together with `before`."
      },
      "SupportIdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": false,
        "schema": {
          "type": "string",
          "format": "uuid"
        },
        "description": "Optional (ARCH-029a \u00a70.5). Same key and request replays the stored\n2xx; another request is 409 `idempotency_key_reused`; still running\nis 409 `request_in_progress`.\n"
      },
      "SupportServiceTenant": {
        "name": "X-Tenant-ID",
        "in": "header",
        "required": true,
        "schema": {
          "type": "string",
          "format": "uuid"
        },
        "description": "Tenant of the turn, case or conversation (service key callers)."
      },
      "SupportHoursQueue": {
        "name": "queue",
        "in": "query",
        "required": false,
        "description": "A queue code, or `tenant` (default) for the desk's default hours.",
        "schema": {
          "type": "string",
          "default": "tenant",
          "example": "l1"
        }
      },
      "SupportTicketId": {
        "name": "ticketId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "format": "uuid"
        },
        "description": "The ticket (its case id). Another customer's or tenant's is 404 `not_found`."
      },
      "SupportTicketState": {
        "name": "state",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string",
          "enum": ["active", "past"],
          "default": "active"
        },
        "description": "`active` (open, waiting_for_you, in_progress) or `past` (resolved, closed, cancelled); anything else is 400 `invalid_filter`."
      },
      "SupportTicketListLimit": {
        "name": "limit",
        "in": "query",
        "required": false,
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100,
          "default": 30
        },
        "description": "Tickets per page; above 100 is clamped; not a positive integer is 400 `invalid_limit`."
      },
      "SupportTicketCursor": {
        "name": "cursor",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string",
          "maxLength": 512
        },
        "description": "`k1.` cursor (`next_cursor`) of the same `state`; another state or a malformed cursor is 400 `invalid_cursor`."
      }
    },
    "schemas": {
      "ReasonBody": {
        "type": "object",
        "required": ["reason"],
        "properties": {
          "reason": {
            "type": "string",
            "minLength": 1,
            "maxLength": 1000
          }
        }
      },
      "TerminateChecks": {
        "type": "object",
        "description": "What terminating a tenant would strand; any non-zero count blocks.",
        "properties": {
          "status": {
            "type": "string"
          },
          "open_accounts": {
            "type": "integer",
            "description": "Accounts not closed (they may hold customer funds)"
          },
          "open_safeguarding_accounts": {
            "type": "integer"
          },
          "safeguarding_balance_accounts": {
            "type": "integer",
            "description": "Safeguarding accounts whose last closing balance is not zero"
          },
          "open_cases": {
            "type": "integer",
            "description": "Compliance cases not closed"
          },
          "blocking": {
            "type": "boolean"
          }
        }
      },
      "PlatformApproval": {
        "type": "object",
        "properties": {
          "request": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "action": {
                "type": "string",
                "enum": [
                  "tenant_terminate",
                  "staff_create_super_admin",
                  "staff_promote_super_admin",
                  "staff_reset_password",
                  "staff_reset_mfa",
                  "staff_grant_bank_admin",
                  "staff_grant_mlro",
                  "licence_pack_change"
                ]
              },
              "target_id": {
                "type": "string"
              },
              "tenant_id": {
                "type": ["string", "null"],
                "format": "uuid"
              },
              "reason": {
                "type": "string"
              },
              "status": {
                "type": "string",
                "enum": [
                  "pending",
                  "approved",
                  "rejected",
                  "withdrawn",
                  "expired"
                ]
              },
              "requested_by": {
                "type": "string",
                "format": "uuid"
              },
              "requested_by_email": {
                "type": "string"
              },
              "requested_at": {
                "type": "string",
                "format": "date-time"
              },
              "expires_at": {
                "type": "string",
                "format": "date-time"
              },
              "decided_by": {
                "type": ["string", "null"],
                "format": "uuid"
              },
              "decided_by_email": {
                "type": ["string", "null"]
              },
              "decided_at": {
                "type": ["string", "null"],
                "format": "date-time"
              },
              "decision_reason": {
                "type": ["string", "null"]
              },
              "can_approve": {
                "type": "boolean",
                "description": "The viewer may approve it now (four-eyes",
                "in time)": null
              },
              "mine": {
                "type": "boolean",
                "description": "The viewer asked for it"
              }
            }
          },
          "payload": {
            "type": "object",
            "description": "What the approver sees (no secrets)"
          },
          "result": {
            "type": ["object", "null"]
          },
          "live_checks": {
            "description": "A pending `tenant_terminate` in a list: the checks run now (the snapshot at asking is `payload.checks`)",
            "$ref": "#/components/schemas/TerminateChecks"
          }
        }
      },
      "PlatformApprovalPending": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": ["pending_approval"]
          },
          "approval": {
            "$ref": "#/components/schemas/PlatformApproval"
          },
          "checks": {
            "$ref": "#/components/schemas/TerminateChecks"
          }
        }
      },
      "StaffScope": {
        "type": "object",
        "description": "Scope of an admin session, server-side (DEC-0017).",
        "properties": {
          "scope": {
            "type": "string",
            "enum": ["cell", "platform", "none"]
          },
          "cell_id": {
            "type": "string"
          },
          "tenant_id": {
            "type": "string",
            "description": "Active tenant (scope cell); empty otherwise"
          },
          "policy": {
            "type": "string",
            "description": "Role inside the cell (scope cell); empty otherwise"
          }
        }
      },
      "SafeguardingAccount": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "currency": {
            "type": "string"
          },
          "method": {
            "type": "string",
            "enum": [
              "segregated_account",
              "secure_assets",
              "insurance",
              "guarantee"
            ]
          },
          "institution_name": {
            "type": "string"
          },
          "institution_bic": {
            "type": "string",
            "nullable": true
          },
          "iban": {
            "type": "string",
            "nullable": true
          },
          "account_name": {
            "type": "string"
          },
          "designation_ref": {
            "type": "string",
            "nullable": true
          },
          "designation_acknowledged_on": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "status": {
            "type": "string",
            "enum": [
              "pending_approval",
              "active",
              "closing_requested",
              "closed",
              "rejected"
            ]
          },
          "created_by": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "approved_by": {
            "type": "string",
            "nullable": true
          },
          "approved_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "close_requested_by": {
            "type": "string",
            "nullable": true
          },
          "close_requested_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "closed_by": {
            "type": "string",
            "nullable": true
          },
          "closed_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "Card": {
        "type": "object",
        "description": "Card metadata stored in the database (BR-EF-017). No PAN/CVV \u2014 sensitive data lives in the card network only.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Internal card ID (database)"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid"
          },
          "customer_id": {
            "type": "string",
            "format": "uuid"
          },
          "account_id": {
            "type": "string",
            "description": "Hex-encoded ledger engine account ID (VARCHAR(64))"
          },
          "marqeta_card_token": {
            "type": "string",
            "description": "Card network provider token (unique, used for provider API calls)"
          },
          "marqeta_user_token": {
            "type": "string",
            "description": "Card network provider user token"
          },
          "last_four": {
            "type": "string",
            "description": "Last 4 digits of PAN",
            "example": "1234"
          },
          "expiry_month": {
            "type": "integer",
            "minimum": 1,
            "maximum": 12
          },
          "expiry_year": {
            "type": "integer"
          },
          "card_type": {
            "type": "string",
            "enum": ["virtual", "physical"]
          },
          "status": {
            "$ref": "#/components/schemas/CardStatus"
          },
          "per_transaction_limit": {
            "type": "integer",
            "nullable": true,
            "description": "Per-transaction spending limit in minor units of per_transaction_limit_currency"
          },
          "per_transaction_limit_currency": {
            "type": "string",
            "nullable": true,
            "example": "EUR",
            "description": "Currency of the card's own per-transaction limit (not part of rules; kept when the card changes rule or account)"
          },
          "daily_limit": {
            "type": "integer",
            "nullable": true,
            "description": "Daily spending limit in minor units"
          },
          "monthly_limit": {
            "type": "integer",
            "nullable": true,
            "description": "Monthly spending limit in minor units (the rule's when on a rule)"
          },
          "yearly_limit": {
            "type": "integer",
            "nullable": true,
            "description": "Yearly (calendar year) spending limit in minor units (the rule's\nwhen on a rule). Always present; null means no limit.\n"
          },
          "online": {
            "type": "boolean",
            "description": "Effective online (card-not-present) switch; same as controls.online"
          },
          "contactless": {
            "type": "boolean",
            "description": "Effective contactless switch; same as controls.contactless"
          },
          "atm": {
            "type": "boolean",
            "description": "Effective ATM (cash withdrawal) switch; same as controls.atm"
          },
          "total_spent": {
            "type": "integer",
            "description": "Lifetime total spent in minor units"
          },
          "wallet_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "Wallet whose account_ids[] holds account_id"
          },
          "currency": {
            "type": "string",
            "nullable": true,
            "example": "EUR",
            "description": "Currency of the funding account (follows PATCH /cards/{id}/account)"
          },
          "limits_currency": {
            "type": "string",
            "nullable": true,
            "example": "EUR",
            "description": "Currency of the limits and spent_* (the rule's currency when on a\nrule, else the card's own limits currency, else `currency`).\nLimits keep it when the funding account changes.\n"
          },
          "rule_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "Rule the card follows; null means custom"
          },
          "rule_name": {
            "type": "string",
            "nullable": true
          },
          "spent_today": {
            "type": "integer",
            "description": "Authorized and settled today, minor units of limits_currency"
          },
          "spent_month": {
            "type": "integer",
            "description": "Authorized and settled this calendar month, minor units of limits_currency"
          },
          "spent_year": {
            "type": "integer",
            "description": "Authorized and settled this calendar year, minor units of limits_currency"
          },
          "controls": {
            "$ref": "#/components/schemas/CardControls"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CardControls": {
        "type": "object",
        "description": "Effective switches (the rule's when the card is on one). The JIT\ngateway declines online (card-not-present) with ONLINE_BLOCKED,\ncontactless with CONTACTLESS_BLOCKED and cash withdrawal (ATM,\nMCC 6011) with ATM_BLOCKED.\n",
        "properties": {
          "online": {
            "type": "boolean"
          },
          "contactless": {
            "type": "boolean"
          },
          "atm": {
            "type": "boolean"
          }
        }
      },
      "CardLimitsInput": {
        "type": "object",
        "description": "Card settings (BR-FM-010): limits in minor units (null or 0 = no\nlimit, stored as null; daily <= monthly <= yearly where set) and\nswitches (default true).\n`per_transaction_limit`, `geo` and `blocked_categories` are not\ncard settings; they are accepted and ignored.\n",
        "properties": {
          "daily_limit": {
            "type": "integer",
            "nullable": true,
            "minimum": 0
          },
          "monthly_limit": {
            "type": "integer",
            "nullable": true,
            "minimum": 0
          },
          "yearly_limit": {
            "type": "integer",
            "nullable": true,
            "minimum": 0
          },
          "online": {
            "type": "boolean"
          },
          "contactless": {
            "type": "boolean"
          },
          "atm": {
            "type": "boolean"
          }
        }
      },
      "CardRuleInput": {
        "type": "object",
        "description": "A rule is an optional template of card settings (see\nCardLimitsInput). `per_transaction_limit`, `geo` and\n`blocked_categories` are accepted and ignored.\n",
        "properties": {
          "customer_id": {
            "type": "string",
            "format": "uuid",
            "description": "Service and admin callers only (create)"
          },
          "name": {
            "type": "string",
            "maxLength": 80
          },
          "currency": {
            "type": "string",
            "example": "EUR"
          },
          "daily_limit": {
            "type": "integer",
            "nullable": true,
            "minimum": 0
          },
          "monthly_limit": {
            "type": "integer",
            "nullable": true,
            "minimum": 0
          },
          "yearly_limit": {
            "type": "integer",
            "nullable": true,
            "minimum": 0
          },
          "online": {
            "type": "boolean"
          },
          "contactless": {
            "type": "boolean"
          },
          "atm": {
            "type": "boolean"
          }
        }
      },
      "CardRule": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "customer_id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "daily_limit": {
            "type": "integer",
            "nullable": true
          },
          "monthly_limit": {
            "type": "integer",
            "nullable": true
          },
          "yearly_limit": {
            "type": "integer",
            "nullable": true
          },
          "online": {
            "type": "boolean"
          },
          "contactless": {
            "type": "boolean"
          },
          "atm": {
            "type": "boolean"
          },
          "card_count": {
            "type": "integer",
            "description": "Cards on the rule that are not terminated or expired"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CardStatus": {
        "type": "string",
        "enum": ["unactivated", "active", "suspended", "terminated"],
        "description": "Card state machine:\nunactivated -> active -> suspended <-> active -> terminated (irreversible)\n"
      },
      "CreateCardRequest": {
        "type": "object",
        "required": [
          "tenant_id",
          "customer_id",
          "account_id",
          "marqeta_card_token",
          "last_four",
          "expiry_month",
          "expiry_year"
        ],
        "properties": {
          "tenant_id": {
            "type": "string",
            "format": "uuid"
          },
          "customer_id": {
            "type": "string",
            "format": "uuid"
          },
          "account_id": {
            "type": "string",
            "description": "Hex-encoded ledger engine account ID"
          },
          "marqeta_card_token": {
            "type": "string"
          },
          "marqeta_user_token": {
            "type": "string"
          },
          "last_four": {
            "type": "string"
          },
          "expiry_month": {
            "type": "integer"
          },
          "expiry_year": {
            "type": "integer"
          },
          "card_type": {
            "type": "string",
            "enum": ["virtual", "physical"],
            "default": "virtual"
          },
          "per_transaction_limit": {
            "type": "integer",
            "nullable": true
          },
          "daily_limit": {
            "type": "integer",
            "nullable": true
          },
          "monthly_limit": {
            "type": "integer",
            "nullable": true
          },
          "yearly_limit": {
            "type": "integer",
            "nullable": true,
            "description": "BR-FM-010; absent = no limit"
          },
          "online": {
            "type": "boolean",
            "description": "BR-FM-010; absent = true"
          },
          "contactless": {
            "type": "boolean",
            "description": "BR-FM-010; absent = true"
          },
          "atm": {
            "type": "boolean",
            "description": "BR-FM-010; absent = true"
          }
        }
      },
      "CardAuthorization": {
        "type": "object",
        "description": "Authorization record for a JIT-funded card transaction.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "card_id": {
            "type": "string",
            "format": "uuid"
          },
          "marqeta_transaction_token": {
            "type": "string",
            "description": "Card network transaction token"
          },
          "network_reference_id": {
            "type": "string",
            "description": "Card network reference for matching clearing/reversal events"
          },
          "amount": {
            "type": "integer",
            "description": "Original network amount in minor units of currency"
          },
          "currency": {
            "type": "string",
            "example": "EUR",
            "description": "Original network currency (currency_code)"
          },
          "account_amount": {
            "type": "integer",
            "nullable": true,
            "description": "Held on the funding account (converted, rounded up, fee included), minor units of account_currency; null before the conversion existed"
          },
          "account_currency": {
            "type": "string",
            "nullable": true,
            "example": "USD"
          },
          "fx_rate": {
            "type": "number",
            "nullable": true,
            "description": "Mid rate used, account_currency per currency (1 when equal)"
          },
          "fx_fee_amount": {
            "type": "integer",
            "nullable": true,
            "description": "Card FX fee in minor units of account_currency (included in account_amount)"
          },
          "limit_amount": {
            "type": "integer",
            "nullable": true,
            "description": "Spend counted against the card limits, minor units of limit_currency"
          },
          "limit_currency": {
            "type": "string",
            "nullable": true,
            "example": "EUR"
          },
          "fx_rate_source": {
            "type": "string",
            "nullable": true,
            "enum": ["live", "fallback", "none"],
            "description": "Live cached rate, static fallback (capped per tenant) or none (same currency)"
          },
          "amount_source": {
            "type": "string",
            "nullable": true,
            "enum": ["original", "billing"],
            "description": "original = amount/currency are the merchant's original (currency_conversion.network); billing = Marqeta amount/currency_code"
          },
          "billing_amount": {
            "type": "integer",
            "nullable": true,
            "description": "Marqeta billing amount when the original was converted"
          },
          "billing_currency": {
            "type": "string",
            "nullable": true
          },
          "funding_account_id": {
            "type": "string",
            "nullable": true,
            "description": "Ledger account the hold debited; refunds credit it"
          },
          "settled_account_amount": {
            "type": "integer",
            "nullable": true,
            "description": "Account amount posted at clearing"
          },
          "settled_fee_amount": {
            "type": "integer",
            "nullable": true,
            "description": "Card FX fee part moved to the platform fee account at clearing"
          },
          "clearing_fx_rate": {
            "type": "number",
            "nullable": true,
            "description": "Mid rate at clearing (account per network)"
          },
          "clearing_fx_diff": {
            "type": "integer",
            "nullable": true,
            "description": "Posted principal minus the cleared amount at the clearing rate (account minor units); positive = FX gain"
          },
          "merchant_name": {
            "type": "string"
          },
          "merchant_mcc": {
            "type": "string",
            "description": "Merchant Category Code"
          },
          "merchant_city": {
            "type": "string"
          },
          "merchant_country": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": ["authorized", "settled", "reversed", "declined", "expired"]
          },
          "jit_funding_token": {
            "type": "string",
            "description": "JIT funding token from card network provider"
          },
          "tigerbeetle_hold_id": {
            "type": "string",
            "description": "Hex-encoded pending hold ID from the ledger engine (internal reference)"
          },
          "settled_amount": {
            "type": "integer",
            "nullable": true,
            "description": "Final settled amount (may differ from authorized amount)"
          },
          "decline_reason": {
            "type": "string",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "AdminUser": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "name": {
            "type": "string"
          },
          "role": {
            "$ref": "#/components/schemas/AdminRole"
          }
        }
      },
      "AdminRole": {
        "type": "string",
        "enum": ["super_admin", "admin", "compliance_officer", "mlro", "viewer"]
      },
      "Tenant": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "legal_name": {
            "type": "string"
          },
          "type": {
            "$ref": "#/components/schemas/TenantType"
          },
          "status": {
            "$ref": "#/components/schemas/TenantStatus"
          },
          "webhook_url": {
            "type": "string",
            "format": "uri"
          },
          "pricing_tier": {
            "type": "string"
          },
          "features": {
            "type": "object",
            "description": "Feature flags JSON"
          },
          "limits": {
            "type": "object",
            "description": "Transfer limits JSON"
          },
          "onboarded_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "TenantType": {
        "type": "string",
        "enum": ["internal", "fintech", "bank", "platform"]
      },
      "TenantStatus": {
        "type": "string",
        "enum": ["pending", "active", "suspended", "terminated"]
      },
      "CreateTenantRequest": {
        "type": "object",
        "required": ["name"],
        "properties": {
          "name": {
            "type": "string"
          },
          "legal_name": {
            "type": "string"
          },
          "type": {
            "$ref": "#/components/schemas/TenantType",
            "default": "fintech"
          },
          "webhook_url": {
            "type": "string",
            "format": "uri",
            "description": "The outgoing notification endpoint: https on any port of a public\nhost (canonical IP, or a name of two or more labels without an\ninternal suffix such as .internal or .localhost). Delivery checks\nevery resolved address again, pins the call to it and follows no\nredirect; an event for an endpoint that fails is recorded\n`failed` with `endpoint_not_allowed` and never sent.\n"
          },
          "pricing_tier": {
            "type": "string",
            "default": "starter"
          },
          "default_currency": {
            "type": "string",
            "example": "EUR"
          },
          "jurisdiction_code": {
            "type": "string",
            "example": "ES"
          },
          "licence_pack": {
            "type": "string",
            "enum": [
              "sandbox",
              "sro",
              "art_1b",
              "full_bank",
              "emi",
              "pi",
              "unscoped",
              "platform_internal"
            ],
            "description": "platform_internal only for type internal. Its home regime must match home_regime."
          },
          "home_regime": {
            "type": "string",
            "enum": ["EU", "CH", "OTHER"]
          },
          "regimes": {
            "type": "array",
            "maxItems": 3,
            "items": {
              "type": "string",
              "enum": ["EU", "CH", "OTHER"]
            },
            "description": "Further regimes; the home regime is always one."
          },
          "data_region": {
            "type": "string",
            "enum": ["eu-central", "ch-zurich"]
          },
          "key_mode": {
            "type": "string",
            "enum": ["platform", "hyok"]
          },
          "cell_id": {
            "type": "string",
            "description": "An existing cell of the bank's jurisdiction."
          },
          "new_cell": {
            "$ref": "#/components/schemas/NewCell"
          },
          "reason": {
            "type": "string",
            "maxLength": 1000
          }
        }
      },
      "NewCell": {
        "type": "object",
        "required": ["id", "label"],
        "description": "A new cell for the bank, of the bank's jurisdiction (not with cell_id).",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9-]{1,62}$"
          },
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          }
        }
      },
      "TenantOnboarding": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string"
          },
          "ready": {
            "type": "boolean"
          },
          "cell_id": {
            "type": ["string", "null"]
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "item": {
                  "type": "string",
                  "enum": [
                    "cell",
                    "kyc_config",
                    "currencies",
                    "products",
                    "bank_admin",
                    "api_key",
                    "sca_policy",
                    "webhook"
                  ]
                },
                "done": {
                  "type": "boolean"
                },
                "count": {
                  "type": "integer"
                }
              }
            }
          },
          "missing": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "CellMembership": {
        "type": "object",
        "properties": {
          "cell_id": {
            "type": "string"
          },
          "cell_label": {
            "type": "string"
          },
          "jurisdiction": {
            "type": "string"
          },
          "policy": {
            "type": "string"
          },
          "active": {
            "type": "boolean"
          },
          "granted_at": {
            "type": "string",
            "format": "date-time"
          },
          "granted_by_email": {
            "type": ["string", "null"]
          },
          "revoked_at": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "revoked_by_email": {
            "type": ["string", "null"]
          },
          "banks": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "tenant_id": {
                  "type": "string",
                  "format": "uuid"
                },
                "name": {
                  "type": "string"
                },
                "status": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "TenantBranding": {
        "type": "object",
        "description": "White-label branding configuration stored as JSONB in finance_tenant.",
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 100,
            "description": "Display name shown in the customer portal. Falls back to tenant.name."
          },
          "logo_url": {
            "type": "string",
            "format": "uri",
            "nullable": true,
            "description": "Light-mode logo URL (HTTPS, max 500 chars). SVG recommended."
          },
          "logo_dark_url": {
            "type": "string",
            "format": "uri",
            "nullable": true,
            "description": "Dark-mode logo URL (HTTPS, max 500 chars). Falls back to logo_url."
          },
          "favicon_url": {
            "type": "string",
            "format": "uri",
            "nullable": true,
            "description": "Browser favicon URL (HTTPS, max 500 chars)."
          },
          "theme_preset": {
            "type": "string",
            "enum": ["default", "ocean", "emerald", "custom"],
            "description": "Color theme preset. Set to \"custom\" to enable primary_color and accent_color."
          },
          "primary_color": {
            "type": "string",
            "nullable": true,
            "pattern": "^\\d{1,3} \\d{1,3}% \\d{1,3}%$",
            "description": "HSL color string (e.g. \"220 70% 50%\"). Applied only when theme_preset = \"custom\"."
          },
          "accent_color": {
            "type": "string",
            "nullable": true,
            "pattern": "^\\d{1,3} \\d{1,3}% \\d{1,3}%$",
            "description": "HSL accent color. Applied only when theme_preset = \"custom\"."
          },
          "support_email": {
            "type": "string",
            "format": "email",
            "nullable": true,
            "description": "Support contact email shown in the customer portal."
          }
        }
      },
      "UpdateBrandingRequest": {
        "type": "object",
        "description": "Partial branding update. Omitted fields are preserved in the JSONB; null or an empty string clears a field.",
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 100,
            "nullable": true
          },
          "logo_url": {
            "type": "string",
            "format": "uri",
            "maxLength": 500,
            "nullable": true
          },
          "logo_dark_url": {
            "type": "string",
            "format": "uri",
            "maxLength": 500,
            "nullable": true
          },
          "favicon_url": {
            "type": "string",
            "format": "uri",
            "maxLength": 500,
            "nullable": true
          },
          "theme_preset": {
            "type": "string",
            "enum": ["default", "ocean", "emerald", "custom"]
          },
          "primary_color": {
            "type": "string",
            "pattern": "^\\d{1,3} \\d{1,3}% \\d{1,3}%$",
            "nullable": true
          },
          "accent_color": {
            "type": "string",
            "pattern": "^\\d{1,3} \\d{1,3}% \\d{1,3}%$",
            "nullable": true
          },
          "support_email": {
            "type": "string",
            "format": "email",
            "maxLength": 254,
            "nullable": true
          },
          "bank_name": {
            "type": "string",
            "maxLength": 120,
            "nullable": true
          },
          "bank_bic": {
            "type": "string",
            "pattern": "^[A-Za-z0-9]{8}([A-Za-z0-9]{3})?$",
            "nullable": true
          },
          "bank_address": {
            "type": "string",
            "maxLength": 200,
            "nullable": true
          },
          "reason": {
            "type": "string",
            "maxLength": 1000,
            "description": "Why the branding changes (1 to 1000 characters): written into the change's audit rows."
          }
        }
      },
      "TenantTheme": {
        "type": "object",
        "description": "Merged tenant theme served by GET /api/v1/tenants/{id}/theme.\nConsumed by the customer portal on server-side render.\n",
        "required": [
          "app_name",
          "theme_preset",
          "default_currency",
          "allowed_currencies",
          "feature_flags"
        ],
        "properties": {
          "app_name": {
            "type": "string",
            "description": "Display name for the portal (branding.name ?? tenant.name)."
          },
          "logo_url": {
            "type": "string",
            "format": "uri",
            "nullable": true
          },
          "logo_dark_url": {
            "type": "string",
            "format": "uri",
            "nullable": true
          },
          "favicon_url": {
            "type": "string",
            "format": "uri",
            "nullable": true
          },
          "theme_preset": {
            "type": "string",
            "enum": ["default", "ocean", "emerald", "custom"]
          },
          "primary_color": {
            "type": "string",
            "nullable": true,
            "description": "HSL string. Present when theme_preset = \"custom\". Falls back to \"220 70% 50%\" if null."
          },
          "accent_color": {
            "type": "string",
            "nullable": true,
            "description": "HSL string. Present when theme_preset = \"custom\"."
          },
          "default_currency": {
            "type": "string",
            "description": "ISO 4217 alpha-3 code. The tenant's default currency for new wallets.",
            "example": "EUR"
          },
          "min_app_build": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000000,
            "description": "Always sent. The oldest app build the tenant's customers may sign\nin with (`sca_policy.min_app_build`, migration 255); 0 is no\nminimum. The app reads it before sign-in and shows \"Update the\napp\" when its own build is lower; identity-api refuses such an\napp at sign-in and token refresh (426 `app_update_required`).\nThe web portal ignores it.\n",
            "example": 0
          },
          "allowed_currencies": {
            "type": "array",
            "description": "ISO 4217 alpha-3 codes of currencies the tenant has enabled. Used to populate currency selection in the customer portal.",
            "items": {
              "type": "string"
            },
            "example": ["EUR", "USD"]
          },
          "customer_portal_url": {
            "type": "string",
            "format": "uri",
            "nullable": true,
            "description": "Public URL of the tenant's white-label customer portal. Consumed by the\nmobile client to resolve deep links and browser hand-off targets for\nthe current tenant. Omitted from the response when unset.\n",
            "example": "https://portal.tenant-example.com"
          },
          "support_email": {
            "type": "string",
            "format": "email",
            "nullable": true,
            "description": "The tenant's support e-mail (branding `support_email`), always sent\n(null when unset). Clients show it when the support thread cannot\nload or `support_chat_enabled` is false (BR-FM-017 FR-12,\nBR-CP-016; ARCH-029a \u00a72.1).\n",
            "example": "soporte@airis.money"
          },
          "feature_flags": {
            "type": "object",
            "description": "Feature flags controlling customer portal capabilities.",
            "properties": {
              "cards_enabled": {
                "type": "boolean"
              },
              "fx_enabled": {
                "type": "boolean"
              },
              "insights_enabled": {
                "type": "boolean"
              },
              "batch_transfers_enabled": {
                "type": "boolean"
              },
              "documents_enabled": {
                "type": "boolean"
              },
              "kyb_enabled": {
                "type": "boolean"
              },
              "assistant_enabled": {
                "type": "boolean"
              },
              "support_chat_enabled": {
                "type": "boolean",
                "description": "Tenant feature `support_chat` (DEC-0032, ARCH-029a \u00a72.1):\ncustomers get the support thread. Off: clients keep the\nsupport e-mail. Absent means off.\n"
              },
              "support_ai_enabled": {
                "type": "boolean",
                "description": "Tenant feature `support_ai` and the platform can run it.\nWhether the AI answers a given thread is that thread's\n`ai_enabled`.\n"
              },
              "support_tickets_enabled": {
                "type": "boolean",
                "description": "Tenant feature `support_tickets` (ARCH-030 \u00a73.1) and the\nplatform can run it (the support bucket answered at boot).\nIndependent of `support_chat_enabled`: clients show Requests\nonly when this is true. Absent means off.\n"
              },
              "sic": {
                "type": "boolean",
                "description": "The tenant may send on the SIC rail (Swiss domestic CHF): the\nlicence pack's enabled rails include `sic` and the tenant\nfeature `sic` (or `sic_ip`) is on, the same check a SIC\ntransfer passes. Clients send CHF to a CH or LI IBAN as\n`transfer_sic` only when this is true, else `transfer_swift`.\n"
              }
            }
          }
        }
      },
      "Customer": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "tenant_id": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": ["individual", "business"]
          },
          "status": {
            "$ref": "#/components/schemas/CustomerStatus"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "first_name": {
            "type": "string"
          },
          "last_name": {
            "type": "string"
          },
          "company_name": {
            "type": "string"
          },
          "phone": {
            "type": "string"
          },
          "country": {
            "type": "string"
          },
          "address_line1": {
            "type": "string"
          },
          "address_line2": {
            "type": "string"
          },
          "city": {
            "type": "string"
          },
          "postal_code": {
            "type": "string"
          },
          "tax_id": {
            "type": "string"
          },
          "kyc_status": {
            "type": "string",
            "enum": ["pending", "in_review", "verified", "rejected"]
          },
          "date_of_birth": {
            "type": "string",
            "format": "date"
          },
          "nationality": {
            "type": "string"
          },
          "metadata": {
            "type": "object",
            "description": "Tenant-specific custom data (JSONB)"
          },
          "external_refs": {
            "type": "object",
            "description": "ERP/CRM/KYC links (JSONB)"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "risk_level": {
            "type": "string",
            "enum": ["low", "medium", "high", "prohibited"],
            "description": "Staff list only (`GET /api/v1/customers`)."
          },
          "account_count": {
            "type": "integer",
            "description": "Staff list only: the customer's accounts that are not closed.\n"
          }
        }
      },
      "CustomerStatus": {
        "type": "string",
        "enum": ["pending", "active", "suspended", "closed"]
      },
      "CustomerOverview": {
        "type": "object",
        "properties": {
          "customer_id": {
            "type": "string",
            "format": "uuid"
          },
          "risk": {
            "type": "object",
            "properties": {
              "level": {
                "type": "string",
                "enum": ["low", "medium", "high", "prohibited"]
              },
              "score": {
                "type": "integer",
                "nullable": true
              }
            }
          },
          "last_kyc_decision": {
            "type": "object",
            "nullable": true,
            "description": "The last KYC approval or rejection.",
            "properties": {
              "status": {
                "type": "string",
                "enum": ["verified", "rejected"]
              },
              "reviewer": {
                "type": "string",
                "nullable": true
              },
              "notes": {
                "type": "string",
                "nullable": true
              },
              "risk_score": {
                "type": "integer",
                "nullable": true
              },
              "reason_code": {
                "type": "string",
                "nullable": true
              },
              "at": {
                "type": "string",
                "format": "date-time"
              }
            }
          },
          "screening": {
            "type": "object",
            "properties": {
              "status": {
                "type": "string",
                "enum": ["not_screened", "clear", "pending_review", "blocked"]
              },
              "last_screened_at": {
                "type": "string",
                "format": "date-time",
                "nullable": true
              }
            }
          },
          "accounts": {
            "type": "object",
            "properties": {
              "total": {
                "type": "integer"
              },
              "active": {
                "type": "integer"
              },
              "frozen": {
                "type": "integer"
              },
              "closing": {
                "type": "integer"
              },
              "closed": {
                "type": "integer"
              },
              "written_off": {
                "type": "integer"
              },
              "frozen_items": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "wallet_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "name": {
                      "type": "string"
                    },
                    "frozen_by": {
                      "type": "string",
                      "enum": ["customer", "bank"],
                      "nullable": true
                    },
                    "since": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "transfers": {
            "type": "object",
            "properties": {
              "pending": {
                "type": "integer"
              },
              "held_incoming": {
                "type": "object",
                "properties": {
                  "count": {
                    "type": "integer"
                  },
                  "amounts": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "currency": {
                          "type": "string"
                        },
                        "amount": {
                          "type": "integer",
                          "description": "Minor units"
                        },
                        "until": {
                          "type": "string",
                          "format": "date-time"
                        }
                      }
                    }
                  }
                }
              },
              "last_at": {
                "type": "string",
                "format": "date-time",
                "nullable": true
              }
            }
          },
          "approvals": {
            "type": "object",
            "properties": {
              "pending": {
                "type": "integer"
              },
              "oldest_at": {
                "type": "string",
                "format": "date-time",
                "nullable": true
              },
              "items": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "amount": {
                      "type": "integer",
                      "description": "Minor units"
                    },
                    "currency": {
                      "type": "string"
                    },
                    "reason": {
                      "type": "string",
                      "nullable": true
                    },
                    "created_at": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "account_changes": {
            "type": "object",
            "properties": {
              "pending": {
                "type": "integer"
              },
              "items": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "action": {
                      "type": "string"
                    },
                    "requested_at": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "cards": {
            "type": "object",
            "properties": {
              "active": {
                "type": "integer"
              },
              "suspended": {
                "type": "integer"
              },
              "unactivated": {
                "type": "integer"
              },
              "ended": {
                "type": "integer"
              }
            }
          },
          "support": {
            "type": "object",
            "properties": {
              "open": {
                "type": "integer"
              },
              "complaints_open": {
                "type": "integer"
              },
              "items": {
                "type": "array",
                "nullable": true,
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "reference": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    },
                    "kind": {
                      "type": "string",
                      "enum": ["chat", "ticket"]
                    },
                    "status": {
                      "type": "string"
                    },
                    "created_at": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "alerts": {
            "type": "object",
            "nullable": true,
            "properties": {
              "open": {
                "type": "integer"
              },
              "items": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "source": {
                      "type": "string",
                      "enum": ["sanctions", "kyc", "cdd", "transfer"]
                    },
                    "id": {
                      "type": "string"
                    },
                    "kind": {
                      "type": "string"
                    },
                    "created_at": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "compliance": {
            "type": "object",
            "nullable": true,
            "properties": {
              "open_cases": {
                "type": "integer"
              },
              "freezes": {
                "type": "integer"
              },
              "items": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "case_type": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "created_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "freeze_until": {
                      "type": "string",
                      "format": "date-time",
                      "nullable": true
                    },
                    "due_at": {
                      "type": "string",
                      "format": "date-time",
                      "nullable": true
                    }
                  }
                }
              }
            }
          },
          "sar_holds": {
            "type": "object",
            "nullable": true,
            "properties": {
              "active": {
                "type": "integer"
              },
              "release_at": {
                "type": "string",
                "format": "date-time",
                "nullable": true
              }
            }
          }
        }
      },
      "CreateCustomerRequest": {
        "type": "object",
        "required": ["tenant_id", "email"],
        "properties": {
          "tenant_id": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": ["individual", "business"],
            "default": "individual"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "first_name": {
            "type": "string"
          },
          "last_name": {
            "type": "string"
          },
          "company_name": {
            "type": "string"
          },
          "phone": {
            "type": "string"
          },
          "country": {
            "type": "string"
          },
          "address_line1": {
            "type": "string"
          },
          "city": {
            "type": "string"
          },
          "postal_code": {
            "type": "string"
          },
          "date_of_birth": {
            "type": "string",
            "format": "date"
          },
          "nationality": {
            "type": "string"
          },
          "legal_name": {
            "type": "string"
          },
          "registration_number": {
            "type": "string"
          },
          "vat_number": {
            "type": "string"
          },
          "legal_form": {
            "type": "string"
          },
          "incorporation_date": {
            "type": "string",
            "format": "date"
          },
          "metadata": {
            "type": "object"
          },
          "external_refs": {
            "type": "object"
          },
          "owner_member": {
            "type": "object",
            "description": "identity-api only (X-Service-Key), business only: the login that\nadds the business becomes its `owner` member, in the same\ntransaction as the customer (SF-add-company-owner-member).\n",
            "required": ["email"],
            "properties": {
              "email": {
                "type": "string",
                "format": "email"
              },
              "name": {
                "type": "string",
                "maxLength": 255,
                "description": "Member name; wins over first_name and last_name"
              },
              "first_name": {
                "type": "string"
              },
              "last_name": {
                "type": "string"
              }
            }
          }
        }
      },
      "UpdateCustomerRequest": {
        "type": "object",
        "properties": {
          "first_name": {
            "type": "string"
          },
          "last_name": {
            "type": "string"
          },
          "company_name": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "phone": {
            "type": "string"
          },
          "country": {
            "type": "string"
          },
          "address_line1": {
            "type": "string"
          },
          "address_line2": {
            "type": "string"
          },
          "city": {
            "type": "string"
          },
          "postal_code": {
            "type": "string"
          },
          "tax_id": {
            "type": "string"
          },
          "date_of_birth": {
            "type": "string",
            "format": "date"
          },
          "nationality": {
            "type": "string"
          },
          "place_of_birth": {
            "type": "string"
          },
          "legal_name": {
            "type": "string"
          },
          "registration_number": {
            "type": "string"
          },
          "vat_number": {
            "type": "string"
          },
          "legal_form": {
            "type": "string"
          },
          "incorporation_date": {
            "type": "string",
            "format": "date"
          },
          "metadata": {
            "type": "object"
          },
          "external_refs": {
            "type": "object"
          }
        }
      },
      "Account": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "iban": {
            "type": "string",
            "example": "DE89PLAN00000000000007"
          },
          "account_name": {
            "type": "string"
          },
          "currency": {
            "$ref": "#/components/schemas/Currency"
          },
          "account_type": {
            "$ref": "#/components/schemas/AccountType"
          },
          "status": {
            "type": "string",
            "enum": ["active", "frozen", "closed", "woff"]
          },
          "customer_id": {
            "type": "string"
          },
          "customer_name": {
            "type": "string"
          },
          "tenant_id": {
            "type": "string"
          },
          "tenant_name": {
            "type": "string"
          },
          "workflow_id": {
            "type": "string",
            "description": "Ledger account ID (hex)"
          },
          "country": {
            "type": "string"
          },
          "woff_reason": {
            "type": "string",
            "nullable": true,
            "description": "IFRS 9 reason (only when status=woff)"
          },
          "woff_date": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "woff_amount": {
            "type": "integer",
            "format": "int64",
            "nullable": true,
            "description": "Balance at write-off time (minor units)"
          },
          "iso_return_code": {
            "type": "string",
            "nullable": true,
            "description": "ISO 20022 code (AC06/MD07/RR04)"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "AccountType": {
        "type": "string",
        "enum": [
          "customer_emoney",
          "platform_fees",
          "platform_fx",
          "safeguarding",
          "safeguarding_backup",
          "nostro",
          "suspense",
          "float_account"
        ]
      },
      "AccountStatusDetail": {
        "type": "object",
        "description": "Why a customer account (wallet) or a ledger account is in its state.",
        "required": ["kind", "status", "events", "stops"],
        "properties": {
          "kind": {
            "type": "string",
            "enum": ["wallet", "account"]
          },
          "status": {
            "type": "string",
            "description": "The account's own status (wallet row; ledger metadata, else the registry row)."
          },
          "frozen_by": {
            "type": ["string", "null"],
            "enum": ["bank", "customer", null],
            "description": "Who froze a frozen customer account; null otherwise and for ledger accounts."
          },
          "wallet_id": {
            "type": ["string", "null"],
            "format": "uuid",
            "description": "The customer account (wallet) the account belongs to; null for the bank's own accounts."
          },
          "customer_id": {
            "type": ["string", "null"],
            "format": "uuid"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "at": {
                  "type": "string",
                  "format": "date-time"
                },
                "kind": {
                  "type": "string",
                  "enum": [
                    "freeze",
                    "unfreeze",
                    "unfreeze_refused",
                    "close",
                    "write_off"
                  ]
                },
                "level": {
                  "type": "string",
                  "enum": ["account", "customer"],
                  "description": "`customer`: a freeze or unfreeze of all of the customer's accounts."
                },
                "actor": {
                  "type": "string",
                  "description": "The actor as the audit row names it."
                },
                "reason": {
                  "type": "string",
                  "description": "The reason as recorded, often a category, a colon and the text."
                },
                "woff_reason": {
                  "type": ["string", "null"]
                }
              }
            }
          },
          "stops": {
            "type": "object",
            "properties": {
              "customer_suspended": {
                "type": "boolean"
              },
              "compliance_hold": {
                "type": "boolean",
                "description": "A compliance hold on the customer or the account."
              },
              "case_count": {
                "type": "integer",
                "description": "Live compliance cases that freeze the account."
              },
              "cases": {
                "type": "array",
                "description": "The live cases by id; empty for roles that do not read compliance cases.",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "case_type": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "opened_at": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "write_off": {
            "type": ["object", "null"],
            "properties": {
              "account_id": {
                "type": "string"
              },
              "reason": {
                "type": "string"
              },
              "date": {
                "type": ["string", "null"],
                "format": "date-time"
              },
              "amount": {
                "type": "integer",
                "format": "int64",
                "description": "Minor units."
              },
              "recovered": {
                "type": "integer",
                "format": "int64",
                "description": "Minor units recovered since."
              },
              "iso_return_code": {
                "type": ["string", "null"]
              },
              "currency": {
                "type": ["string", "null"]
              }
            }
          }
        }
      },
      "AccountBalance": {
        "type": "object",
        "properties": {
          "account_id": {
            "type": "string"
          },
          "iban": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "total_balance": {
            "type": "integer",
            "format": "int64",
            "description": "All funds including pending (posted+pending credits minus posted+pending debits)"
          },
          "available_balance": {
            "type": "integer",
            "format": "int64",
            "description": "Funds available for withdrawal (posted credits minus posted debits minus pending debits)"
          },
          "pending_debits": {
            "type": "integer",
            "format": "int64"
          },
          "pending_credits": {
            "type": "integer",
            "format": "int64"
          },
          "posted_debits": {
            "type": "integer",
            "format": "int64"
          },
          "posted_credits": {
            "type": "integer",
            "format": "int64"
          }
        }
      },
      "CreateAccountRequest": {
        "type": "object",
        "required": ["account_id"],
        "properties": {
          "account_id": {
            "type": "string",
            "description": "Hex ledger account ID"
          },
          "workspace_id": {
            "type": "integer"
          },
          "owner_id": {
            "type": "integer"
          },
          "tenant_type": {
            "$ref": "#/components/schemas/AccountType",
            "default": "workspace_master"
          },
          "ledger": {
            "type": "integer",
            "description": "Ledger ID (currency code)"
          },
          "name": {
            "type": "string"
          },
          "iban": {
            "type": "string"
          }
        }
      },
      "WalletStatusReply": {
        "type": "object",
        "description": "Reply of a wallet freeze or unfreeze.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "enum": ["active", "frozen", "closed"]
          },
          "frozen_by": {
            "type": "string",
            "nullable": true,
            "enum": ["customer", "bank", null],
            "description": "Who froze the wallet (see Wallet.frozen_by); null when not frozen."
          }
        }
      },
      "Wallet": {
        "type": "object",
        "description": "A wallet has one ledger account per currency (`account_ids`); `currency`\nis the wallet's own currency. Multiple wallets per currency allowed;\nuniqueness by name (migration 059). Primary wallet (`is_primary: true`)\ncannot be closed or frozen. `is_primary` describes the wallet; the Main\naccount is only the primary wallet's own currency (`is_main`,\n`main_currency`, BR-CP-003 \u00a74.4).\n",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": ["personal", "business"],
            "default": "personal"
          },
          "status": {
            "type": "string",
            "enum": ["active", "frozen", "closed"]
          },
          "frozen_by": {
            "type": "string",
            "nullable": true,
            "enum": ["customer", "bank", null],
            "description": "Who froze a frozen wallet (migration 175): `customer` (the customer\nmay unfreeze it) or `bank` (staff, compliance, a service; also a\nfreeze placed before 175). Null when the wallet is not frozen.\nReturned by the wallet list, the customer's wallet list and the\nwallet detail.\n"
          },
          "currency": {
            "$ref": "#/components/schemas/Currency"
          },
          "customer_id": {
            "type": "string",
            "format": "uuid"
          },
          "customer_name": {
            "type": "string",
            "description": "The customer's name (staff wallet list)."
          },
          "tenant_id": {
            "type": "string",
            "description": "The wallet's bank (staff wallet list)."
          },
          "daily_spending_limit": {
            "type": ["integer", "null"],
            "format": "int64",
            "description": "Minor units of the wallet's currency (wallet detail); null when not set."
          },
          "monthly_spending_limit": {
            "type": ["integer", "null"],
            "format": "int64",
            "description": "Minor units (wallet detail); null when not set."
          },
          "single_transaction_limit": {
            "type": ["integer", "null"],
            "format": "int64",
            "description": "Minor units (wallet detail); null when not set."
          },
          "is_primary": {
            "type": "boolean",
            "default": false,
            "description": "Primary wallet \u2014 auto-created on KYC verification, cannot be closed or frozen. Wallet-level flag; do not show it as Main on every currency (use account_ids[].is_main)."
          },
          "main_currency": {
            "type": "string",
            "nullable": true,
            "description": "The Main account's currency (the primary wallet's own `currency`); null for other wallets.",
            "example": "EUR"
          },
          "written_off": {
            "type": "boolean",
            "description": "List rows only. A ledger account of the wallet is written off (its status stays the wallet's own)."
          },
          "approval_pending": {
            "type": "boolean",
            "description": "List rows only. A change of the wallet or one of its ledger accounts waits for a second officer."
          },
          "iban": {
            "type": "string",
            "description": "IBAN of the wallet's own currency (compatibility). Each currency account's IBAN is in account_ids[].iban.",
            "example": "DE89PLAN00000000000001"
          },
          "country": {
            "type": "string",
            "description": "Country code from IBAN registry",
            "example": "DE"
          },
          "bic": {
            "type": "string",
            "description": "BIC of the wallet's own-currency IBAN (`iban`): the IBAN registry\nrow's, else the account metadata's for that IBAN, else the one\nits national bank code names (ES ..2100: CAIXESBBXXX), else the\ntenant's `branding.bank_bic`. Empty string when none is known.\nReturned by GET /api/v1/wallets/{walletId}, GET /api/v1/wallets\nand GET /api/v1/customers/{customerId}/wallets.\n",
            "example": "CAIXESBBXXX"
          },
          "bank_name": {
            "type": "string",
            "description": "Name of the bank that holds the account, as the receiving details\nshow it: the tenant's `branding.bank_name`, else its legal name.\nEmpty string when neither is set.\n",
            "example": "AIRIS MONEY EDE, S.L."
          },
          "bank_address": {
            "type": "string",
            "description": "The bank's registered address (the tenant's\n`branding.bank_address`). Empty string when not configured.\n",
            "example": "Calle Gran V\u00eda 1, 28013 Madrid"
          },
          "account_ids": {
            "type": "array",
            "description": "Ledger engine account references",
            "items": {
              "type": "object",
              "properties": {
                "tb_id": {
                  "type": "string",
                  "description": "Hex-encoded ledger engine 128-bit account ID"
                },
                "currency": {
                  "$ref": "#/components/schemas/Currency"
                },
                "decimals": {
                  "type": "integer",
                  "description": "ISO 4217 exponent of this account's currency (GET /api/v1/customers/{customerId}/wallets)"
                },
                "is_main": {
                  "type": "boolean",
                  "description": "True only for the primary wallet's own-currency account (the Main account). Returned by GET /api/v1/customers/{customerId}/wallets."
                },
                "iban": {
                  "type": "string",
                  "nullable": true,
                  "description": "This currency account's own IBAN (tenant jurisdiction; DEC-0015). Null until provisioned. Returned by GET /api/v1/customers/{customerId}/wallets.",
                  "example": "ES8921000418430000000024"
                },
                "bic": {
                  "type": "string",
                  "nullable": true,
                  "example": "CAIXESBBXXX"
                },
                "account_number": {
                  "type": "string",
                  "nullable": true,
                  "description": "Domestic account number next to the IBAN. Set for USD (US-style secondary details), else null.",
                  "example": "400000000024"
                },
                "routing_number": {
                  "type": "string",
                  "nullable": true,
                  "description": "ABA routing number (valid checksum) for USD accounts, else null.",
                  "example": "026009593"
                },
                "bank_name": {
                  "type": "string",
                  "nullable": true
                }
              }
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreateWalletRequest": {
        "type": "object",
        "required": ["name"],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 50,
            "description": "Unique wallet name per customer (active wallets only)"
          },
          "customer_id": {
            "type": "string",
            "format": "uuid",
            "description": "FK to finance_customer. Required for customer-scoped wallets."
          },
          "currency": {
            "$ref": "#/components/schemas/Currency",
            "description": "Currency of the wallet's first ledger account (the wallet's own currency). Defaults to EUR.",
            "default": "EUR"
          },
          "is_primary": {
            "type": "boolean",
            "default": false,
            "description": "Mark as primary wallet (cannot be closed). Typically set only during auto-provisioning."
          }
        }
      },
      "WalletCreditDebitRequest": {
        "type": "object",
        "required": ["amount", "currency"],
        "properties": {
          "amount": {
            "type": "integer",
            "format": "int64",
            "minimum": 1,
            "description": "Amount in minor units"
          },
          "currency": {
            "$ref": "#/components/schemas/Currency"
          },
          "reference": {
            "type": "string"
          }
        }
      },
      "IntegrationProvider": {
        "type": "object",
        "description": "Database-backed integration provider from finance_integration_provider\n(migration 057). Unique constraint: (domain, provider_name, tenant_id).\n",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "domain": {
            "type": "string",
            "enum": ["banking", "kyc", "kyb", "aml", "payment", "card", "fx"],
            "description": "Integration domain category"
          },
          "provider_name": {
            "type": "string",
            "description": "Machine-readable provider key (e.g. core_banking)"
          },
          "display_name": {
            "type": "string",
            "description": "Human-readable provider name"
          },
          "status": {
            "type": "string",
            "enum": ["active", "inactive", "maintenance"]
          },
          "config": {
            "type": "object",
            "description": "Provider-specific JSONB configuration"
          },
          "capabilities": {
            "type": "object",
            "description": "Supported features/operations (JSONB)"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "Tenant-specific override (null = global)"
          },
          "priority": {
            "type": "integer",
            "description": "Resolution priority (lower = higher priority)",
            "default": 100
          },
          "sandbox_mode": {
            "type": "boolean",
            "default": false
          },
          "api_url": {
            "type": "string",
            "format": "uri",
            "nullable": true
          },
          "webhook_url": {
            "type": "string",
            "format": "uri",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreateIntegrationProviderRequest": {
        "type": "object",
        "required": ["domain", "provider_name", "display_name"],
        "properties": {
          "domain": {
            "type": "string",
            "enum": ["banking", "kyc", "kyb", "aml", "payment", "card", "fx"]
          },
          "provider_name": {
            "type": "string"
          },
          "display_name": {
            "type": "string"
          },
          "config": {
            "type": "object"
          },
          "capabilities": {
            "type": "object"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "priority": {
            "type": "integer",
            "default": 100
          },
          "sandbox_mode": {
            "type": "boolean",
            "default": false
          },
          "api_url": {
            "type": "string",
            "format": "uri"
          },
          "webhook_url": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "Transfer": {
        "type": "object",
        "description": "Transfer list item (returned by GET /transfers)",
        "properties": {
          "id": {
            "type": "string",
            "description": "Hex ledger transfer ID"
          },
          "transfer_id": {
            "type": "string",
            "description": "Same as id (legacy alias)"
          },
          "reference": {
            "type": "string",
            "description": "Human-readable reference"
          },
          "description": {
            "type": "string"
          },
          "external_id": {
            "type": "string",
            "description": "External system reference"
          },
          "status": {
            "$ref": "#/components/schemas/TransferStatus"
          },
          "from_wallet_id": {
            "type": "string",
            "description": "Debit account hex ID"
          },
          "to_wallet_id": {
            "type": "string",
            "description": "Credit account hex ID"
          },
          "from_name": {
            "type": "string",
            "description": "Debit side as the account holder sees it: the account name or\nIBAN; for a platform account (master, settlement, fees), which is\nnever named, the payer recorded on the transfer\n(`counterparty_name`), else `\"\"`.\n"
          },
          "to_name": {
            "type": "string",
            "description": "Credit side as the account holder sees it: the account name or\nIBAN; for a platform account the payee (`destination_name`, then\n`counterparty_name`), else `\"\"`.\n"
          },
          "amount": {
            "type": "integer",
            "format": "int64",
            "description": "Amount in minor units"
          },
          "currency": {
            "$ref": "#/components/schemas/Currency"
          },
          "event_type": {
            "type": "string",
            "description": "Transfer classification (deposit, withdrawal, transfer_sepa_sct, fx_conversion, etc.)"
          },
          "rail": {
            "type": "string",
            "enum": [
              "internal",
              "sepa_sct",
              "sepa_inst",
              "sic",
              "sic_ip",
              "swift",
              "card",
              "fx",
              "fee",
              "other"
            ],
            "description": "History lists only (customer, account): the rail in the timeline\nvocabulary (DEC-0030), from the rail stored at creation, else the\nevent type. A direct debit is `other`.\n"
          },
          "value_date": {
            "type": "string",
            "format": "date",
            "description": "Value date (Wertstellungsdatum)"
          },
          "booking_date": {
            "type": "string",
            "format": "date",
            "description": "Accounting booking date"
          },
          "workflow_id": {
            "type": "string",
            "description": "Durable workflow execution ID"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "settlement_status": {
            "type": "string",
            "description": "Staff list and detail: the holding period of an incoming\npayment (SETTLED_PENDING, SETTLED_AVAILABLE, SETTLED_RETURNED,\nSETTLED_EXPIRED), `\"\"` without one.\n"
          },
          "held_until": {
            "type": "string",
            "description": "Staff list and detail. End of the holding period, `\"\"` without one."
          },
          "outcome_step": {
            "type": "string",
            "enum": ["", "returned", "failed", "cancelled"],
            "description": "Staff list and detail: the latest provider step that ended the\ntransfer (returned before failed before cancelled), `\"\"` when\nnone was recorded.\n"
          },
          "outcome_code": {
            "type": "string",
            "description": "Staff list and detail: the step's status code (e.g. RJCT), `\"\"` without one."
          },
          "outcome_reason": {
            "type": "string",
            "description": "Staff list and detail: the step's ISO 20022 reason (e.g. AC01), `\"\"` without one."
          },
          "from_customer_id": {
            "type": "string",
            "description": "Staff list and detail: the customer whose account the debit leg is, `\"\"` for a bank or external account."
          },
          "from_customer_name": {
            "type": "string",
            "description": "Staff list and detail. Its display name."
          },
          "from_account_id": {
            "type": "string",
            "description": "Staff list and detail: the customer account (wallet id) of the debit leg."
          },
          "to_customer_id": {
            "type": "string",
            "description": "Staff list and detail: the customer of the credit leg, `\"\"` for a bank or external account."
          },
          "to_customer_name": {
            "type": "string",
            "description": "Staff list and detail. Its display name."
          },
          "to_account_id": {
            "type": "string",
            "description": "Staff list and detail: the customer account (wallet id) of the credit leg."
          }
        }
      },
      "TransferDetail": {
        "type": "object",
        "description": "Full transfer detail (returned by GET /transfers/{transferId}).\nExtends the list item with fee breakdown, account IDs, FX conversion\ndetails, SEPA payment rails, tenant context, R-transaction status,\nand audit metadata. FX and R-transaction blocks are conditional.\n",
        "allOf": [
          {
            "$ref": "#/components/schemas/Transfer"
          },
          {
            "type": "object",
            "properties": {
              "fee_amount": {
                "type": "integer",
                "format": "int64",
                "description": "Applied fee in minor units"
              },
              "fee_schedule_id": {
                "type": "string",
                "format": "uuid",
                "description": "Fee schedule used for calculation"
              },
              "debit_account_id": {
                "type": "string",
                "description": "Hex debit ledger account ID"
              },
              "credit_account_id": {
                "type": "string",
                "description": "Hex credit ledger account ID"
              },
              "destination_iban": {
                "type": "string",
                "description": "Recipient IBAN (credit account)"
              },
              "sender_iban": {
                "type": "string",
                "description": "Sender IBAN (debit account)"
              },
              "correlation_id": {
                "type": "string",
                "description": "Links related transfers (e.g. FX legs)"
              },
              "causation_id": {
                "type": "string",
                "description": "Links reversals to originating transfer"
              },
              "ledger": {
                "type": "string",
                "description": "Ledger code"
              },
              "sepa_end_to_end_id": {
                "type": "string",
                "description": "SEPA End-to-End ID for bank reconciliation"
              },
              "transfer_type": {
                "type": "string",
                "description": "Raw transfer type (may differ from event_type enum)"
              },
              "tenant_id": {
                "type": "string",
                "format": "uuid"
              },
              "tenant_name": {
                "type": "string"
              },
              "metadata": {
                "type": "object",
                "description": "Type-specific JSONB (fx_pair, tier, override, leg, etc.)"
              },
              "fx_from_currency": {
                "type": "string",
                "description": "Source currency (conditional)"
              },
              "fx_to_currency": {
                "type": "string",
                "description": "Target currency (conditional)"
              },
              "fx_from_amount": {
                "type": "string",
                "description": "Source amount in minor units as string (conditional)"
              },
              "fx_to_amount": {
                "type": "string",
                "description": "Target amount in minor units as string (conditional)"
              },
              "fx_rate": {
                "type": "string",
                "description": "Applied exchange rate (conditional)"
              },
              "fx_spread_bps": {
                "type": "string",
                "description": "Applied spread in basis points (conditional)"
              },
              "fx_fee_amount": {
                "type": "integer",
                "format": "int64",
                "description": "FX conversion fee in minor units (conditional)"
              },
              "r_transaction_type": {
                "type": "string",
                "enum": ["REJECT", "RETURN", "REFUND", "REVERSAL"],
                "description": "SEPA R-transaction classification (conditional)"
              },
              "r_transaction_reason": {
                "type": "string",
                "description": "ISO 20022 reason code, e.g. AC01, FRAD, MD07 (conditional)"
              },
              "r_transaction_info": {
                "type": "string",
                "description": "Additional R-transaction information (conditional)"
              },
              "r_original_transfer_id": {
                "type": "string",
                "description": "Link to original transfer (conditional)"
              },
              "from_account_name": {
                "type": "string",
                "description": "Name of the debit leg's customer account."
              },
              "to_account_name": {
                "type": "string",
                "description": "Name of the credit leg's customer account."
              },
              "approval_status": {
                "type": "string",
                "description": "The transfer's approval (a limit held it for a second\nofficer): pending_review, approved, rejected, expired or\nfailed; `\"\"` when none was needed.\n"
              },
              "approval_limit_reason": {
                "type": "string",
                "description": "The limit that held it; empty without an approval."
              },
              "approval_requested_at": {
                "type": "string",
                "description": "When it was held."
              },
              "approval_resolved_at": {
                "type": "string",
                "description": "When it was decided."
              },
              "approval_requested_by": {
                "type": "string",
                "description": "customer, staff or service."
              },
              "approval_id": {
                "type": "string",
                "description": "The approval's id."
              }
            }
          }
        ]
      },
      "TransferStatus": {
        "type": "string",
        "enum": [
          "pending",
          "pending_review",
          "completed",
          "failed",
          "rejected",
          "returned",
          "cancelled",
          "voided"
        ]
      },
      "CreateTransferRequest": {
        "type": "object",
        "required": ["from_account_id", "to_account_id", "amount", "currency"],
        "properties": {
          "from_account_id": {
            "type": "string",
            "description": "Hex ledger account ID"
          },
          "to_account_id": {
            "type": "string"
          },
          "amount": {
            "type": "integer",
            "format": "int64",
            "minimum": 1
          },
          "currency": {
            "$ref": "#/components/schemas/Currency"
          },
          "event_type": {
            "type": "string",
            "description": "Transfer type for TB code mapping and holding period resolution. Defaults to transfer_internal.",
            "enum": [
              "deposit",
              "withdrawal",
              "transfer_internal",
              "transfer_sepa_sct",
              "transfer_sepa_instant",
              "transfer_sepa_dd",
              "transfer_swift",
              "transfer_sic",
              "transfer_sic_instant",
              "sepa_sct",
              "sepa_instant",
              "sepa_sdd",
              "direct_debit",
              "swift",
              "sic",
              "sic_ip",
              "fx_conversion",
              "fee",
              "cash_deposit",
              "woff_recovery",
              "woff_adjustment"
            ]
          },
          "transaction_code": {
            "type": "string",
            "description": "ISO transaction code for posting engine mapping (e.g. PMNT-RCDT-ESCT). Triggers posting audit when present with tenant_id."
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid",
            "description": "Tenant UUID for holding period and posting engine resolution"
          },
          "customer_id": {
            "type": "string",
            "format": "uuid",
            "description": "Customer UUID for customer-specific config resolution. Ignored for customer JWTs (the JWT customer is used)."
          },
          "beneficiary_id": {
            "type": "string",
            "format": "uuid",
            "description": "Saved payee paid by this transfer. Must be the caller's own and match destination_iban (or account and routing) and destination_name."
          },
          "expected_total_debit": {
            "type": "integer",
            "format": "int64",
            "description": "Optional (0.31.0, DEC-0038). The total in minor units the client showed (the fee preview's `total_debit`). When it differs from the total this transfer debits, 409 `{\"error\":\"fee_changed\",\"total_debit\":<new>}`, nothing posted or parked for approval. Not an integer is 400 `invalid_expected_total_debit`."
          },
          "destination_name": {
            "type": "string"
          },
          "destination_iban": {
            "type": "string"
          },
          "destination_bic": {
            "type": "string"
          },
          "destination_account_number": {
            "type": "string"
          },
          "destination_routing_number": {
            "type": "string"
          },
          "charge_bearer": {
            "type": "string",
            "enum": ["slev", "sha", "our", "ben"],
            "description": "Who bears the charges, per rail (DEC-0038, 0.31.0). Our fee is\nalways charged on top (the sender's), except SWIFT `ben`.\nSEPA SCT, SCT Inst, SIC, SIC IP: stored and sent as `slev`\nwhatever is sent (`our`, `sha`, `slev` or absent); `ben` (any\ncase) is 422 `charge_bearer_not_allowed`. SWIFT: `sha`\n(default), `our` or `ben` (any case); `ben` takes our fee off\nthe amount sent; `our` is stored and sent as `sha` unless the\npreview offers OUR (an OUR price and a beneficiary bank outside\nthe EEA); anything else, `slev` included, is 400\n`invalid_charge_bearer` (DEC-0030). Internal and FPS: no bearer\nis stored; `ben` is 422 `charge_bearer_not_allowed`. Send the\nfee preview's `default_charge_bearer` (or a chosen entry of\n`charge_bearer_options`). Stored in the transfer metadata for\nSEPA, SIC and SWIFT.\n"
          },
          "intermediary_bic": {
            "type": "string",
            "description": "SWIFT only. Intermediary bank BIC (ISO 9362, 8 or 11 characters, any case, stored upper case). Invalid is 400 `invalid_intermediary_bic`. A SWIFT `destination_bic` is checked the same way (400 `invalid_destination_bic`)."
          },
          "purpose_code": {
            "type": "string",
            "description": "SWIFT only. ISO 20022 external purpose code, four letters (SUPP, SALA, ...). Invalid is 400 `invalid_purpose_code`."
          },
          "remittance_info": {
            "type": "string",
            "maxLength": 140,
            "description": "SWIFT only. Remittance text (MT103 70, pacs.008 RmtInf/Ustrd), up to 140 characters without control characters (400 `invalid_remittance_info`). Default the reference, else the description, cut to 140."
          },
          "counterparty_name": {
            "type": "string",
            "maxLength": 140,
            "description": "The other party as the account holder should see it: the payer of\na credit (for example a salary booked from the tenant nostro), the\npayee of a debit. Returned in transaction listings as `from_name`\n/ `to_name` where the other leg is a platform account.\n\nPlain text, at most 140 characters after sanitising: control\ncharacters and line breaks become spaces, bidi and zero-width\ncharacters and `<` `>` are removed, whitespace is collapsed and\ntrimmed; blank counts as not sent. Longer: 400\n`counterparty_name_too_long`; invalid text: 400\n`counterparty_name_invalid`.\n\nAccepted from staff and service-key callers. A customer JWT may\nsend it only together with a `beneficiary_id` (its own saved\npayee), else 403 `counterparty_name_not_allowed`.\n"
          }
        }
      },
      "CreateHoldRequest": {
        "type": "object",
        "required": ["from_account_id", "amount", "currency"],
        "properties": {
          "from_account_id": {
            "type": "string"
          },
          "to_account_id": {
            "type": "string"
          },
          "amount": {
            "type": "integer",
            "format": "int64",
            "minimum": 1
          },
          "currency": {
            "$ref": "#/components/schemas/Currency"
          }
        }
      },
      "Currency": {
        "type": "string",
        "description": "ISO 4217 code. Every amount is in minor units of its own currency, with\nthe ISO exponent from GET /api/v1/currencies: EUR 2 (1 EUR = 100),\nJPY and KRW 0 (1 JPY = 1), KWD and BHD 3 (1 KWD = 1000).\n",
        "enum": [
          "EUR",
          "USD",
          "GBP",
          "CHF",
          "PLN",
          "SEK",
          "NOK",
          "DKK",
          "CZK",
          "AED",
          "JPY",
          "KRW",
          "KWD",
          "BHD"
        ]
      },
      "CurrencyInfo": {
        "type": "object",
        "required": ["code", "decimals", "name"],
        "properties": {
          "code": {
            "$ref": "#/components/schemas/Currency"
          },
          "decimals": {
            "type": "integer",
            "enum": [0, 2, 3],
            "description": "ISO 4217 minor-unit exponent"
          },
          "name": {
            "type": "string",
            "example": "Euro"
          }
        }
      },
      "CountryCode": {
        "type": "string",
        "enum": [
          "DE",
          "AT",
          "CH",
          "FR",
          "NL",
          "BE",
          "ES",
          "IT",
          "GB",
          "IE",
          "PT",
          "LU"
        ]
      },
      "FxQuoteRequest": {
        "type": "object",
        "required": ["from_currency", "to_currency", "amount"],
        "properties": {
          "from_currency": {
            "$ref": "#/components/schemas/Currency"
          },
          "to_currency": {
            "$ref": "#/components/schemas/Currency"
          },
          "amount": {
            "type": "integer",
            "format": "int64"
          }
        }
      },
      "FxQuote": {
        "type": "object",
        "properties": {
          "quote_id": {
            "type": "string"
          },
          "from": {
            "$ref": "#/components/schemas/Currency"
          },
          "to": {
            "$ref": "#/components/schemas/Currency"
          },
          "from_amount": {
            "type": "integer",
            "format": "int64",
            "description": "Amount to convert, in FROM minor units"
          },
          "net_amount": {
            "type": "integer",
            "format": "int64",
            "description": "from_amount minus fee_amount (FROM minor units)"
          },
          "to_amount": {
            "type": "integer",
            "format": "int64",
            "description": "Credited amount in TO minor units:\nround(net_amount / 10^from_decimals * rate * 10^to_decimals),\nrounded half away from zero. The conversion books exactly this.\n"
          },
          "fee_amount": {
            "type": "integer",
            "format": "int64",
            "description": "FX fee in FROM minor units"
          },
          "rate": {
            "type": "number",
            "description": "Mid-market rate, TO major units per FROM major unit (8 decimals)"
          },
          "spread_bps": {
            "type": "integer",
            "description": "Fee percentage in basis points"
          },
          "valid_until": {
            "type": "integer",
            "format": "int64",
            "description": "Unix seconds"
          },
          "from_decimals": {
            "type": "integer",
            "description": "ISO exponent of FROM"
          },
          "to_decimals": {
            "type": "integer",
            "description": "ISO exponent of TO"
          }
        }
      },
      "FxConvertRequest": {
        "type": "object",
        "required": [
          "from_account_id",
          "to_account_id",
          "amount",
          "from_currency",
          "to_currency"
        ],
        "properties": {
          "from_account_id": {
            "type": "string"
          },
          "to_account_id": {
            "type": "string"
          },
          "amount": {
            "type": "integer",
            "format": "int64"
          },
          "from_currency": {
            "$ref": "#/components/schemas/Currency"
          },
          "to_currency": {
            "$ref": "#/components/schemas/Currency"
          },
          "quote_id": {
            "type": "string",
            "description": "Quote from POST /api/v1/fx/quote; its amounts, fee and rate are executed exactly once."
          }
        }
      },
      "TransactionLimit": {
        "type": "object",
        "description": "A transaction limit (migration 266). Values are minor units of\n`currency` (null currency: the EUR equivalent); null = no limit,\n0 = nothing allowed. A customer-scope row is an override with a\nnote. Deleted rows are kept (`deleted_at`). The limit applies only\nbetween `valid_from` and `valid_until` (every level of the transfer\nlimit check).\n",
        "properties": {
          "id": {
            "type": "string"
          },
          "tenant_id": {
            "type": "string"
          },
          "tenant_name": {
            "type": "string",
            "nullable": true
          },
          "customer_id": {
            "type": "string",
            "nullable": true
          },
          "customer_name": {
            "type": "string",
            "nullable": true
          },
          "account_id": {
            "type": "string",
            "nullable": true
          },
          "scope": {
            "type": "string",
            "enum": ["tenant", "customer", "account"]
          },
          "limit_type": {
            "type": "string",
            "enum": ["default", "override", "aml_provider"]
          },
          "customer_type_default": {
            "type": "string",
            "nullable": true,
            "enum": ["individual", "business", null]
          },
          "single_transaction_limit": {
            "type": "integer",
            "format": "int64",
            "nullable": true
          },
          "daily_limit": {
            "type": "integer",
            "format": "int64",
            "nullable": true
          },
          "monthly_limit": {
            "type": "integer",
            "format": "int64",
            "nullable": true
          },
          "currency": {
            "type": "string",
            "nullable": true
          },
          "notes": {
            "type": "string",
            "nullable": true
          },
          "valid_from": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "The limit applies from then on"
          },
          "valid_until": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "The limit applies before then; null is open ended"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "created_by": {
            "type": "string",
            "nullable": true
          },
          "deleted_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "deleted_by": {
            "type": "string",
            "nullable": true
          },
          "delete_reason": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "CreateLimitRequest": {
        "type": "object",
        "required": [
          "currency",
          "single_transaction_limit",
          "daily_limit",
          "monthly_limit"
        ],
        "properties": {
          "tenant_id": {
            "type": "string"
          },
          "customer_id": {
            "type": "string"
          },
          "account_id": {
            "type": "string",
            "description": "Ledger account id (hex)"
          },
          "single_transaction_limit": {
            "type": "integer",
            "format": "int64",
            "minimum": 0,
            "nullable": true
          },
          "daily_limit": {
            "type": "integer",
            "format": "int64",
            "minimum": 0,
            "nullable": true
          },
          "monthly_limit": {
            "type": "integer",
            "format": "int64",
            "minimum": 0,
            "nullable": true
          },
          "currency": {
            "$ref": "#/components/schemas/Currency"
          },
          "notes": {
            "type": "string",
            "maxLength": 1000,
            "description": "Required for a customer"
          },
          "customer_type_default": {
            "type": "string",
            "enum": ["individual", "business"]
          },
          "valid_from": {
            "type": "string",
            "nullable": true,
            "description": "ISO 8601 date or timestamp from which the limit applies; absent\nor null: now. Without an offset (a bare date, a time without\n`Z` or `+01:00`) it is a time of the bank's day, in its\njurisdiction's time zone. A customer or account limit only: a\nbank default applies from now (400 `limit_window_invalid`,\n`field` valid_from).\n"
          },
          "valid_until": {
            "type": "string",
            "nullable": true,
            "description": "ISO 8601 date or timestamp until which the limit applies\n(exclusive), resolved like valid_from; absent or null: open\nended. After valid_from and in the future, else 400\n`limit_window_invalid`. A customer or account limit only: a bank\ndefault has no end (400 `limit_window_invalid`, `field`\nvalid_until).\n"
          }
        }
      },
      "CustomerLimitOverrideRequest": {
        "type": "object",
        "required": [
          "currency",
          "single_transaction_limit",
          "daily_limit",
          "monthly_limit",
          "notes"
        ],
        "properties": {
          "currency": {
            "type": "string",
            "example": "EUR"
          },
          "single_transaction_limit": {
            "type": "integer",
            "format": "int64",
            "minimum": 0,
            "nullable": true
          },
          "daily_limit": {
            "type": "integer",
            "format": "int64",
            "minimum": 0,
            "nullable": true
          },
          "monthly_limit": {
            "type": "integer",
            "format": "int64",
            "minimum": 0,
            "nullable": true
          },
          "notes": {
            "type": "string",
            "minLength": 3,
            "maxLength": 1000
          },
          "valid_from": {
            "type": "string",
            "nullable": true,
            "description": "ISO 8601 date or timestamp from which the limit applies; absent\nor null: now. Without an offset (a bare date, a time without\n`Z` or `+01:00`) it is a time of the bank's day, in its\njurisdiction's time zone. Outside the window the bank default\napplies.\n"
          },
          "valid_until": {
            "type": "string",
            "nullable": true,
            "description": "ISO 8601 date or timestamp until which the limit applies\n(exclusive), resolved like valid_from; absent or null: open\nended. After valid_from and in the future, else 400\n`limit_window_invalid`. Outside the window the bank default\napplies.\n"
          },
          "replace": {
            "type": "boolean",
            "description": "`true`: the officer confirmed that this windowed override\nreplaces the customer's override in force now in this currency.\nWithout it such a request is 409 `limit_replace_required`.\n"
          }
        }
      },
      "ResolvedCustomerLimits": {
        "type": "object",
        "properties": {
          "customer_id": {
            "type": "string",
            "format": "uuid"
          },
          "currency": {
            "type": "string"
          },
          "source": {
            "type": "string",
            "enum": [
              "override",
              "aml_provider",
              "type_default",
              "tenant_default",
              "none"
            ]
          },
          "limit_id": {
            "type": "string"
          },
          "notes": {
            "type": "string"
          },
          "single_transaction_limit": {
            "type": "integer",
            "format": "int64",
            "nullable": true
          },
          "daily_limit": {
            "type": "integer",
            "format": "int64",
            "nullable": true
          },
          "monthly_limit": {
            "type": "integer",
            "format": "int64",
            "nullable": true
          },
          "daily_used": {
            "type": "integer",
            "format": "int64"
          },
          "monthly_used": {
            "type": "integer",
            "format": "int64"
          }
        }
      },
      "ReasonRequest": {
        "type": "object",
        "required": ["reason"],
        "properties": {
          "reason": {
            "type": "string",
            "minLength": 3,
            "maxLength": 1000,
            "description": "Kept in the audit log"
          }
        }
      },
      "IctIncidentDeadline": {
        "type": "object",
        "description": "One reporting obligation that applies (DEC-0044). `due_at` null\nwith `asap` true: as soon as possible (FDPIC).\n",
        "required": ["kind", "report", "due_at", "met_at", "asap"],
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "dora_initial",
              "dora_intermediate",
              "dora_final",
              "finma_initial",
              "finma_ehp",
              "ncsc",
              "fdpic"
            ]
          },
          "report": {
            "type": "string",
            "enum": ["initial", "intermediate", "final", "ncsc", "fdpic"]
          },
          "due_at": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "met_at": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "asap": {
            "type": "boolean"
          }
        }
      },
      "IctIncidentReportSent": {
        "type": ["object", "null"],
        "properties": {
          "reported_at": {
            "type": "string",
            "format": "date-time"
          },
          "reference": {
            "type": ["string", "null"]
          }
        }
      },
      "IctIncident": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "affected_services": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "regime": {
            "type": "string",
            "enum": ["EU", "CH"]
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "classified",
              "reported_initial",
              "reported_intermediate",
              "reported_final",
              "closed"
            ]
          },
          "detected_at": {
            "type": "string",
            "format": "date-time"
          },
          "classified_at": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "reportable_since": {
            "type": ["string", "null"],
            "format": "date-time",
            "description": "When the incident first entered a class with reporting duties (significant or major). The deadlines run from it; it never moves."
          },
          "classification": {
            "type": ["string", "null"],
            "enum": ["major", "significant", "minor", null]
          },
          "criteria": {
            "type": "object",
            "properties": {
              "clients_affected": {
                "type": ["integer", "null"]
              },
              "duration_minutes": {
                "type": ["integer", "null"]
              },
              "countries_affected": {
                "type": ["integer", "null"]
              },
              "data_losses": {
                "type": ["boolean", "null"]
              },
              "critical_services_affected": {
                "type": ["boolean", "null"]
              },
              "economic_impact_minor": {
                "type": ["integer", "null"],
                "description": "Minor units of `economic_impact_currency`."
              },
              "economic_impact_currency": {
                "type": ["string", "null"]
              }
            }
          },
          "cyber_attack": {
            "type": "boolean"
          },
          "personal_data_breach": {
            "type": "boolean"
          },
          "reports": {
            "type": "object",
            "properties": {
              "initial": {
                "$ref": "#/components/schemas/IctIncidentReportSent"
              },
              "intermediate": {
                "$ref": "#/components/schemas/IctIncidentReportSent"
              },
              "final": {
                "$ref": "#/components/schemas/IctIncidentReportSent"
              },
              "ncsc": {
                "$ref": "#/components/schemas/IctIncidentReportSent"
              },
              "fdpic": {
                "$ref": "#/components/schemas/IctIncidentReportSent"
              }
            }
          },
          "root_cause_resolution": {
            "type": ["string", "null"]
          },
          "created_by_email": {
            "type": ["string", "null"]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "closed_at": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "closed_by_email": {
            "type": ["string", "null"]
          },
          "legacy_case_id": {
            "type": ["string", "null"],
            "format": "uuid",
            "description": "The compliance case this incident was moved from (migration 276)."
          },
          "deadlines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/IctIncidentDeadline"
            }
          },
          "next_due_at": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "events": {
            "type": "array",
            "description": "The timeline, oldest first (one incident only).",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "event_type": {
                  "type": "string",
                  "enum": [
                    "created",
                    "updated",
                    "classified",
                    "reported",
                    "closed",
                    "migrated"
                  ]
                },
                "actor_email": {
                  "type": ["string", "null"]
                },
                "actor_role": {
                  "type": ["string", "null"]
                },
                "detail": {
                  "type": "object"
                },
                "created_at": {
                  "type": "string",
                  "format": "date-time"
                }
              }
            }
          }
        }
      },
      "EddChecklistItem": {
        "type": "object",
        "required": ["key", "required"],
        "properties": {
          "key": {
            "type": "string"
          },
          "label": {
            "type": ["string", "null"],
            "description": "The bank's label; null for a default item (the portal translates it)."
          },
          "guidance": {
            "type": ["string", "null"]
          },
          "required": {
            "type": "boolean"
          },
          "position": {
            "type": "integer"
          }
        }
      },
      "EddChecklist": {
        "type": "object",
        "required": ["source", "items", "defaults", "mandatory"],
        "properties": {
          "source": {
            "type": "string",
            "enum": ["bank", "platform"]
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EddChecklistItem"
            }
          },
          "defaults": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EddChecklistItem"
            }
          },
          "mandatory": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "EddChecklistUpdate": {
        "type": "object",
        "required": ["items"],
        "properties": {
          "items": {
            "type": "array",
            "maxItems": 20,
            "items": {
              "type": "object",
              "required": ["key"],
              "properties": {
                "key": {
                  "type": "string",
                  "pattern": "^[a-z][a-z0-9_]{1,47}$"
                },
                "label": {
                  "type": "string",
                  "minLength": 3,
                  "maxLength": 200
                },
                "guidance": {
                  "type": "string",
                  "maxLength": 1000
                },
                "required": {
                  "type": "boolean",
                  "default": true
                }
              }
            }
          }
        }
      },
      "EddReview": {
        "type": "object",
        "required": [
          "id",
          "status",
          "customer_id",
          "screening_result_id",
          "opened_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "enum": ["open", "awaiting_decision", "approved", "rejected"]
          },
          "customer_id": {
            "type": "string",
            "format": "uuid"
          },
          "screening_result_id": {
            "type": "string",
            "format": "uuid"
          },
          "trigger_kind": {
            "type": "string",
            "enum": ["pep_confirmed"]
          },
          "trigger": {
            "type": "object",
            "description": "The confirmed match as it was (subject_name, highest_score, match_count, provider, confirmed_by, confirmed_at, match).",
            "additionalProperties": true
          },
          "trigger_notes": {
            "type": ["string", "null"]
          },
          "supersedes_id": {
            "type": ["string", "null"],
            "format": "uuid",
            "description": "The rejected review this one follows."
          },
          "reopen_reason": {
            "type": ["string", "null"]
          },
          "superseded_by": {
            "type": ["string", "null"],
            "format": "uuid",
            "description": "The new review that follows this rejected one."
          },
          "opened_by_email": {
            "type": "string"
          },
          "opened_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "previous_risk_level": {
            "type": ["string", "null"]
          },
          "recommendation": {
            "type": ["object", "null"],
            "properties": {
              "decision": {
                "type": "string",
                "enum": ["approve", "reject"]
              },
              "reason": {
                "type": "string"
              },
              "reject_action": {
                "type": ["string", "null"],
                "enum": ["offboard", "restrict", null]
              },
              "by_email": {
                "type": "string"
              },
              "at": {
                "type": "string",
                "format": "date-time"
              }
            }
          },
          "decision": {
            "type": ["object", "null"],
            "properties": {
              "decision": {
                "type": "string",
                "enum": ["approve", "reject"]
              },
              "reason": {
                "type": "string"
              },
              "by_email": {
                "type": "string"
              },
              "at": {
                "type": "string",
                "format": "date-time"
              },
              "outcome": {
                "type": "string",
                "enum": [
                  "cleared",
                  "still_held",
                  "closure_initiated",
                  "kyc_rejected",
                  "suspended",
                  "held",
                  "already_ending"
                ]
              }
            }
          },
          "customer": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "name": {
                "type": "string"
              },
              "type": {
                "type": "string"
              },
              "status": {
                "type": "string"
              },
              "kyc_status": {
                "type": ["string", "null"]
              },
              "screening_status": {
                "type": "string"
              },
              "risk_level": {
                "type": "string"
              },
              "date_of_birth": {
                "type": ["string", "null"],
                "format": "date"
              },
              "nationality": {
                "type": ["string", "null"]
              },
              "country": {
                "type": ["string", "null"]
              }
            }
          },
          "items_required": {
            "type": "integer"
          },
          "items_required_done": {
            "type": "integer"
          },
          "items_total": {
            "type": "integer"
          }
        }
      },
      "EddReviewList": {
        "type": "object",
        "required": [
          "reviews",
          "open_count",
          "awaiting_count",
          "decided_count"
        ],
        "properties": {
          "reviews": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EddReview"
            }
          },
          "open_count": {
            "type": "integer"
          },
          "awaiting_count": {
            "type": "integer"
          },
          "decided_count": {
            "type": "integer"
          }
        }
      },
      "EddReviewDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/EddReview"
          },
          {
            "type": "object",
            "properties": {
              "checklist": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "key": {
                      "type": "string"
                    },
                    "label": {
                      "type": ["string", "null"]
                    },
                    "guidance": {
                      "type": ["string", "null"]
                    },
                    "required": {
                      "type": "boolean"
                    },
                    "status": {
                      "type": "string",
                      "enum": ["open", "done", "not_applicable"]
                    },
                    "note": {
                      "type": ["string", "null"]
                    },
                    "updated_by_email": {
                      "type": ["string", "null"]
                    },
                    "updated_at": {
                      "type": ["string", "null"],
                      "format": "date-time"
                    }
                  }
                }
              },
              "documents": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "cdd_document_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "item_key": {
                      "type": ["string", "null"]
                    },
                    "note": {
                      "type": ["string", "null"]
                    },
                    "attached_by_email": {
                      "type": "string"
                    },
                    "attached_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "document_type": {
                      "type": ["string", "null"]
                    },
                    "object_key": {
                      "type": ["string", "null"],
                      "description": "KYC media key (null once the copy was deleted after retention)."
                    },
                    "accepted_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "deleted": {
                      "type": "boolean"
                    }
                  }
                }
              },
              "available_documents": {
                "type": "array",
                "description": "The customer's CDD register documents not yet attached.",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "document_type": {
                      "type": ["string", "null"]
                    },
                    "object_key": {
                      "type": "string"
                    },
                    "accepted_at": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              },
              "monitoring": {
                "type": ["object", "null"],
                "properties": {
                  "status": {
                    "type": "string"
                  },
                  "provider_profile": {
                    "type": "boolean"
                  },
                  "since": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "last_check": {
                    "type": ["string", "null"],
                    "format": "date-time"
                  }
                }
              },
              "screening_result": {
                "type": ["object", "null"],
                "additionalProperties": true
              },
              "events": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "event_type": {
                      "type": "string",
                      "enum": [
                        "opened",
                        "risk_raised",
                        "monitoring_enrolled",
                        "item_updated",
                        "note",
                        "document_attached",
                        "submitted",
                        "returned",
                        "approved",
                        "rejected",
                        "migrated",
                        "reopened",
                        "superseded",
                        "screening_held"
                      ]
                    },
                    "actor_email": {
                      "type": ["string", "null"]
                    },
                    "actor_role": {
                      "type": ["string", "null"]
                    },
                    "detail": {
                      "type": "object",
                      "additionalProperties": true
                    },
                    "created_at": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              },
              "consequences": {
                "type": "object",
                "properties": {
                  "approve": {
                    "type": "string",
                    "enum": ["cleared", "still_held"]
                  },
                  "reject_offboard": {
                    "type": "string",
                    "enum": [
                      "closure_initiated",
                      "kyc_rejected",
                      "already_ending"
                    ]
                  },
                  "reject_restrict": {
                    "type": "string",
                    "enum": ["suspended", "held", "already_ending"]
                  }
                }
              },
              "viewer": {
                "type": "object",
                "properties": {
                  "may_work": {
                    "type": "boolean"
                  },
                  "may_decide": {
                    "type": "boolean"
                  },
                  "is_submitter": {
                    "type": "boolean"
                  },
                  "may_reopen": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        ]
      },
      "EddCustomerReviews": {
        "type": "object",
        "description": "Roles other than mlro, auditor and super_admin get `customer_id`,\n`status` and `open_review_id` only (no `reviews`).\n",
        "required": ["customer_id", "status", "open_review_id"],
        "properties": {
          "customer_id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": ["string", "null"],
            "enum": ["open", "awaiting_decision", "approved", "rejected", null],
            "description": "The review not yet decided, else the newest one."
          },
          "open_review_id": {
            "type": ["string", "null"],
            "format": "uuid"
          },
          "reviews": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "status": {
                  "type": "string",
                  "enum": ["open", "awaiting_decision", "approved", "rejected"]
                },
                "screening_result_id": {
                  "type": "string",
                  "format": "uuid"
                },
                "opened_at": {
                  "type": "string",
                  "format": "date-time"
                },
                "decided_at": {
                  "type": ["string", "null"],
                  "format": "date-time"
                },
                "decided_by_email": {
                  "type": ["string", "null"]
                },
                "outcome": {
                  "type": ["string", "null"]
                }
              }
            }
          }
        }
      },
      "EddItemUpdate": {
        "type": "object",
        "required": ["status"],
        "properties": {
          "status": {
            "type": "string",
            "enum": ["open", "done", "not_applicable"]
          },
          "note": {
            "type": "string",
            "maxLength": 2000,
            "description": "Required (10 characters at least) for done and not_applicable."
          }
        }
      },
      "EddNote": {
        "type": "object",
        "required": ["text"],
        "properties": {
          "text": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2000
          }
        }
      },
      "EddDocumentAttach": {
        "type": "object",
        "required": ["cdd_document_id"],
        "properties": {
          "cdd_document_id": {
            "type": "string",
            "format": "uuid"
          },
          "item_key": {
            "type": "string"
          },
          "note": {
            "type": "string",
            "maxLength": 2000
          }
        }
      },
      "EddSubmit": {
        "type": "object",
        "required": ["recommendation", "reason"],
        "properties": {
          "recommendation": {
            "type": "string",
            "enum": ["approve", "reject"]
          },
          "reason": {
            "type": "string",
            "minLength": 10,
            "maxLength": 4000
          },
          "reject_action": {
            "type": "string",
            "enum": ["offboard", "restrict"],
            "description": "Required with reject."
          }
        }
      },
      "EddDecide": {
        "type": "object",
        "required": ["decision", "reason"],
        "properties": {
          "decision": {
            "type": "string",
            "enum": ["approve", "reject", "return"]
          },
          "reason": {
            "type": "string",
            "minLength": 10,
            "maxLength": 4000
          }
        }
      },
      "IctIncidentList": {
        "type": "object",
        "required": [
          "incidents",
          "open_count",
          "closed_count",
          "overdue_count"
        ],
        "properties": {
          "incidents": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/IctIncident"
            }
          },
          "open_count": {
            "type": "integer"
          },
          "closed_count": {
            "type": "integer"
          },
          "overdue_count": {
            "type": "integer"
          }
        }
      },
      "IctIncidentCreate": {
        "type": "object",
        "required": ["title", "affected_services", "detected_at"],
        "properties": {
          "title": {
            "type": "string",
            "minLength": 3,
            "maxLength": 200
          },
          "description": {
            "type": "string",
            "maxLength": 4000
          },
          "affected_services": {
            "type": "array",
            "minItems": 1,
            "maxItems": 20,
            "items": {
              "type": "string",
              "maxLength": 100
            }
          },
          "detected_at": {
            "type": "string",
            "format": "date-time",
            "description": "Not in the future."
          },
          "cyber_attack": {
            "type": "boolean",
            "default": false
          },
          "personal_data_breach": {
            "type": "boolean",
            "default": false
          }
        }
      },
      "IctIncidentUpdate": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string",
            "minLength": 3,
            "maxLength": 200
          },
          "description": {
            "type": "string",
            "maxLength": 4000
          },
          "affected_services": {
            "type": "array",
            "minItems": 1,
            "maxItems": 20,
            "items": {
              "type": "string",
              "maxLength": 100
            }
          },
          "detected_at": {
            "type": "string",
            "format": "date-time"
          },
          "cyber_attack": {
            "type": "boolean"
          },
          "personal_data_breach": {
            "type": "boolean"
          }
        }
      },
      "IctIncidentClassify": {
        "type": "object",
        "required": ["classification"],
        "properties": {
          "classification": {
            "type": "string",
            "enum": ["major", "significant", "minor"]
          },
          "clients_affected": {
            "type": "integer",
            "minimum": 0
          },
          "duration_minutes": {
            "type": "integer",
            "minimum": 0
          },
          "countries_affected": {
            "type": "integer",
            "minimum": 0
          },
          "data_losses": {
            "type": "boolean"
          },
          "critical_services_affected": {
            "type": "boolean"
          },
          "economic_impact_minor": {
            "type": "integer",
            "minimum": 0
          },
          "economic_impact_currency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$"
          },
          "cyber_attack": {
            "type": "boolean"
          },
          "personal_data_breach": {
            "type": "boolean"
          }
        }
      },
      "IctIncidentReport": {
        "type": "object",
        "required": ["kind", "reported_at"],
        "properties": {
          "kind": {
            "type": "string",
            "enum": ["initial", "intermediate", "final", "ncsc", "fdpic"]
          },
          "reported_at": {
            "type": "string",
            "format": "date-time"
          },
          "reference": {
            "type": "string",
            "maxLength": 200
          }
        }
      },
      "IctThirdParty": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "provider_name": {
            "type": "string"
          },
          "service_provided": {
            "type": "string"
          },
          "supports_critical_function": {
            "type": "boolean"
          },
          "contract_start": {
            "type": ["string", "null"],
            "format": "date"
          },
          "contract_end": {
            "type": ["string", "null"],
            "format": "date"
          },
          "data_location": {
            "type": "string"
          },
          "subcontractors": {
            "type": "string"
          },
          "exit_plan": {
            "type": "string"
          },
          "created_by_email": {
            "type": ["string", "null"]
          },
          "updated_by_email": {
            "type": ["string", "null"]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "IctThirdPartyInput": {
        "type": "object",
        "required": ["provider_name", "service_provided"],
        "properties": {
          "provider_name": {
            "type": "string",
            "minLength": 2,
            "maxLength": 200
          },
          "service_provided": {
            "type": "string",
            "minLength": 2,
            "maxLength": 500
          },
          "supports_critical_function": {
            "type": "boolean",
            "default": false
          },
          "contract_start": {
            "type": ["string", "null"],
            "format": "date"
          },
          "contract_end": {
            "type": ["string", "null"],
            "format": "date"
          },
          "data_location": {
            "type": "string",
            "maxLength": 200
          },
          "subcontractors": {
            "type": "string",
            "maxLength": 1000
          },
          "exit_plan": {
            "type": "string",
            "maxLength": 4000,
            "description": "At least 10 characters when the service supports a critical or important function."
          }
        }
      },
      "WebhookEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "tenant_id": {
            "type": "string"
          },
          "tenant_name": {
            "type": "string"
          },
          "event_type": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": ["pending", "delivered", "failed", "retrying"]
          },
          "attempts": {
            "type": "integer"
          },
          "max_attempts": {
            "type": "integer"
          },
          "last_attempt_at": {
            "type": "string",
            "format": "date-time"
          },
          "next_retry_at": {
            "type": "string",
            "format": "date-time"
          },
          "delivered_at": {
            "type": "string",
            "format": "date-time"
          },
          "last_error": {
            "type": "string"
          },
          "webhook_url": {
            "type": "string",
            "format": "uri"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "AuditEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "event_type": {
            "type": "string",
            "description": "Event code (audit.zig EventType)"
          },
          "entity_type": {
            "type": "string",
            "description": "Entity code (audit.zig EntityType)"
          },
          "entity_id": {
            "type": "string"
          },
          "actor_type": {
            "type": "string",
            "description": "Actor code (audit.zig ActorType)"
          },
          "actor_id": {
            "type": "string"
          },
          "tenant_id": {
            "type": "string"
          },
          "workspace_id": {
            "type": "string"
          },
          "event_hash": {
            "type": "string",
            "description": "SHA-256 hash (chain link)"
          },
          "previous_hash": {
            "type": "string"
          },
          "created_at": {
            "type": "string"
          },
          "data": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "Hold": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "hold_id": {
            "type": "string"
          },
          "card_id": {
            "type": "string"
          },
          "account_id": {
            "type": "string"
          },
          "amount": {
            "type": "integer",
            "format": "int64",
            "description": "Amount in minor units"
          },
          "currency": {
            "$ref": "#/components/schemas/Currency"
          },
          "merchant_name": {
            "type": "string"
          },
          "merchant_category": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": ["pending", "captured", "voided", "expired"]
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "captured_amount": {
            "type": "integer",
            "format": "int64"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "BankStatement": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "statement_id": {
            "type": "string"
          },
          "account_iban": {
            "type": "string"
          },
          "currency": {
            "$ref": "#/components/schemas/Currency"
          },
          "statement_type": {
            "type": "string"
          },
          "entry_count": {
            "type": "integer"
          },
          "matched_count": {
            "type": "integer"
          },
          "unmatched_count": {
            "type": "integer"
          },
          "total_credits": {
            "type": "integer",
            "format": "int64"
          },
          "total_debits": {
            "type": "integer",
            "format": "int64"
          },
          "opening_balance": {
            "type": "integer",
            "format": "int64"
          },
          "closing_balance": {
            "type": "integer",
            "format": "int64"
          },
          "status": {
            "type": "string",
            "enum": ["imported", "matched", "partial", "approved"]
          },
          "reviewed_by": {
            "type": "string"
          },
          "reviewed_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "StatementEntry": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "statement_id": {
            "type": "string",
            "format": "uuid"
          },
          "entry_date": {
            "type": "string",
            "format": "date"
          },
          "value_date": {
            "type": "string",
            "format": "date"
          },
          "amount": {
            "type": "integer",
            "format": "int64",
            "description": "Minor units"
          },
          "currency": {
            "type": "string"
          },
          "credit_debit": {
            "type": "string",
            "enum": ["CRDT", "DBIT"]
          },
          "end_to_end_id": {
            "type": "string"
          },
          "debtor_name": {
            "type": "string"
          },
          "creditor_name": {
            "type": "string"
          },
          "remittance_info": {
            "type": "string"
          },
          "match_status": {
            "type": "string",
            "enum": [
              "unmatched",
              "exact",
              "amount_only",
              "ref_only",
              "partial",
              "manual_match",
              "investigated",
              "rejected"
            ]
          },
          "match_confidence": {
            "type": "number",
            "format": "float",
            "minimum": 0,
            "maximum": 1
          },
          "matched_transfer_id": {
            "type": "string",
            "nullable": true
          },
          "review_note": {
            "type": "string",
            "nullable": true
          },
          "reviewed_by": {
            "type": "string",
            "nullable": true
          },
          "reviewed_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "FxRateHistory": {
        "type": "object",
        "properties": {
          "currency": {
            "type": "string",
            "description": "Quote currency (base is always EUR)"
          },
          "rate": {
            "type": "number",
            "format": "double"
          },
          "previous_rate": {
            "type": "number",
            "format": "double"
          },
          "source": {
            "type": "string",
            "enum": ["alpha_vantage", "static_refresh", "manual_override"]
          },
          "change_type": {
            "type": "string",
            "enum": ["refresh", "override", "override_ended"]
          },
          "changed_by": {
            "type": "string",
            "description": "staff:<id> for a manual change (empty for automated; older rows: free text)"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "FxOverrideApplied": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": ["applied"]
          },
          "quote_currency": {
            "type": "string"
          },
          "rate": {
            "type": "number"
          },
          "market_rate": {
            "type": "number"
          },
          "deviation_bps": {
            "type": "integer"
          },
          "band_bps": {
            "type": "integer",
            "example": 500
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "previous_rate": {
            "type": ["number", "null"]
          },
          "approved_by": {
            "type": ["string", "null"],
            "format": "uuid"
          }
        }
      },
      "TenantWebhookEndpoint": {
        "type": "object",
        "properties": {
          "tenant_id": {
            "type": "string",
            "format": "uuid"
          },
          "webhook_url": {
            "type": ["string", "null"]
          }
        }
      },
      "FxSpreadConfig": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "base_currency": {
            "type": "string",
            "example": "EUR"
          },
          "quote_currency": {
            "type": "string",
            "example": "USD"
          },
          "spread_bps": {
            "type": "integer",
            "description": "Spread in basis points"
          },
          "min_spread_bps": {
            "type": "integer"
          },
          "max_spread_bps": {
            "type": "integer"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid",
            "description": "Empty for global default"
          },
          "is_active": {
            "type": "boolean"
          },
          "updated_by": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "HoldingPeriodConfig": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "tenant_id": {
            "type": "string"
          },
          "customer_id": {
            "type": "string",
            "description": "Empty string if tenant-level default"
          },
          "customer_group": {
            "type": "string"
          },
          "payment_method": {
            "type": "string",
            "enum": ["SEPA_SDD", "SEPA_SDD_B2B", "SEPA_SCT", "CARD", "OTHER"]
          },
          "holding_days": {
            "type": "integer",
            "minimum": 0,
            "maximum": 30
          },
          "calendar_type": {
            "type": "string",
            "enum": ["CALENDAR", "BUSINESS"]
          },
          "risk_score": {
            "type": "string",
            "enum": ["LOW", "MEDIUM", "HIGH", ""]
          },
          "auto_adjust": {
            "type": "boolean"
          },
          "is_active": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string"
          },
          "updated_at": {
            "type": "string"
          }
        }
      },
      "TransactionCodeMapping": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "tenant_id": {
            "type": "string"
          },
          "customer_id": {
            "type": "string",
            "description": "Empty string if tenant/global level"
          },
          "transaction_code": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "target_account_id": {
            "type": "string",
            "description": "Ledger account hex ID"
          },
          "posting_type": {
            "type": "string",
            "enum": ["CREDIT", "DEBIT"]
          },
          "payment_method": {
            "type": "string"
          },
          "is_active": {
            "type": "boolean"
          }
        }
      },
      "PostingAuditEntry": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "tenant_id": {
            "type": "string"
          },
          "transaction_code": {
            "type": "string"
          },
          "original_transaction_id": {
            "type": "string"
          },
          "target_account_id": {
            "type": "string"
          },
          "posting_type": {
            "type": "string",
            "enum": ["CREDIT", "DEBIT"]
          },
          "amount": {
            "type": "integer",
            "format": "int64"
          },
          "currency": {
            "type": "string"
          },
          "posting_result": {
            "type": "string",
            "enum": ["SUCCESS", "SUSPENSE", "MANUAL_REVIEW", "FAILED"]
          },
          "error_message": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "decision": {
            "type": "string",
            "nullable": true,
            "enum": ["resolved", "rejected", null]
          },
          "decided_account_id": {
            "type": "string",
            "nullable": true
          },
          "decision_reason": {
            "type": "string",
            "nullable": true
          },
          "decided_by_ref": {
            "type": "string",
            "nullable": true
          },
          "decided_at": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "PostingReviewDecision": {
        "type": "object",
        "description": "An append-only decision on an unassigned booking (migration 267); no money moves.",
        "properties": {
          "decision": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "tenant_id": {
                "type": "string",
                "format": "uuid"
              },
              "posting_audit_id": {
                "type": "string",
                "format": "uuid"
              },
              "decision": {
                "type": "string",
                "enum": ["resolved", "rejected"]
              },
              "target_account_id": {
                "type": "string",
                "nullable": true
              },
              "reason": {
                "type": "string"
              },
              "decided_by": {
                "type": "string",
                "format": "uuid"
              },
              "decided_by_ref": {
                "type": "string"
              },
              "decided_at": {
                "type": "string",
                "format": "date-time"
              }
            }
          },
          "moves_money": {
            "type": "boolean",
            "example": false
          }
        }
      },
      "KycVerificationConfig": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid"
          },
          "config_type": {
            "type": "string",
            "enum": ["kyc", "kyb"]
          },
          "name": {
            "type": "string"
          },
          "provider_config_id": {
            "type": "string",
            "description": "KYC provider configuration ID"
          },
          "verification_tier": {
            "type": "integer"
          },
          "auto_approve_enabled": {
            "type": "boolean"
          },
          "auto_approve_min_similarity": {
            "type": "number"
          },
          "screening_enabled": {
            "type": "boolean"
          },
          "screening_min_score": {
            "type": "integer"
          },
          "screening_datasets": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "screening_run_after": {
            "type": "string",
            "enum": ["completion", "approval"]
          },
          "session_lifetime_minutes": {
            "type": "integer"
          },
          "default_language": {
            "type": "string"
          },
          "supported_languages": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "allowed_document_types": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "allowed_document_countries": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "require_liveness": {
            "type": "boolean"
          },
          "liveness_type": {
            "type": "string",
            "enum": ["passive", "active"]
          },
          "require_proof_of_address": {
            "type": "boolean"
          },
          "require_selfie_with_id": {
            "type": "boolean"
          },
          "require_geolocation": {
            "type": "boolean"
          },
          "require_phone_verification": {
            "type": "boolean"
          },
          "require_email_verification": {
            "type": "boolean"
          },
          "questionnaire": {
            "type": "object"
          },
          "is_active": {
            "type": "boolean"
          },
          "created_by": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "KycSession": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "customer_id": {
            "type": "string",
            "format": "uuid"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid"
          },
          "config_id": {
            "type": "string",
            "format": "uuid"
          },
          "provider_session_token": {
            "type": "string",
            "description": "KYC provider session token"
          },
          "session_type": {
            "type": "string",
            "enum": ["kyc", "kyb"]
          },
          "status": {
            "type": "string",
            "enum": [
              "created",
              "approved",
              "rejected",
              "manual_check",
              "expired"
            ]
          },
          "person_data": {
            "type": "object"
          },
          "similarity_score": {
            "type": "number"
          },
          "reject_reason": {
            "type": "string"
          },
          "reject_description": {
            "type": "string"
          },
          "widget_url": {
            "type": "string"
          },
          "callback_received_at": {
            "type": "string",
            "format": "date-time"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "OfficerReason": {
        "type": "object",
        "description": "An officer's reason for a status change (staff); written to the audit rows.",
        "required": ["reason_category", "reason"],
        "properties": {
          "reason_category": {
            "type": "string",
            "pattern": "^[a-z_]{2,40}$",
            "description": "e.g. customer_request, fraud_suspected, compliance_review, court_order, credit_loss, other."
          },
          "reason": {
            "type": "string",
            "minLength": 10,
            "maxLength": 1000
          }
        }
      },
      "OpsApproval": {
        "type": "object",
        "description": "A request for a second officer on an account action (migration 268).",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "action": {
            "type": "string",
            "enum": [
              "wallet_unfreeze",
              "wallet_close",
              "account_unfreeze",
              "account_close",
              "account_write_off"
            ]
          },
          "subject_type": {
            "type": "string",
            "enum": ["wallet", "account"]
          },
          "subject_id": {
            "type": "string",
            "description": "Wallet UUID or ledger account id (hex)."
          },
          "subject_status": {
            "type": "string",
            "description": "The subject's status when the request was written."
          },
          "status": {
            "type": "string",
            "enum": ["pending", "approved", "rejected", "withdrawn"]
          },
          "payload": {
            "type": "object",
            "properties": {
              "reason_category": {
                "type": "string"
              },
              "reason": {
                "type": "string"
              },
              "woff_reason": {
                "type": "string"
              }
            }
          },
          "subject": {
            "type": ["object", "null"],
            "description": "Wallet: name, currency, status, customer_id, customer_name, iban. Ledger account: name, status, woff_amount, currency, iban, customer_id, customer_name (the account's customer, when it has one)."
          },
          "requested_by": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "email": {
                "type": "string"
              },
              "role": {
                "type": "string"
              }
            }
          },
          "requested_at": {
            "type": "string",
            "format": "date-time"
          },
          "decided_by": {
            "type": ["object", "null"],
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "email": {
                "type": "string"
              },
              "role": {
                "type": "string"
              }
            }
          },
          "decided_at": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "decision_reason": {
            "type": ["string", "null"]
          },
          "approver_available": {
            "type": "boolean"
          },
          "can": {
            "type": "object",
            "properties": {
              "approve": {
                "type": "boolean"
              },
              "reject": {
                "type": "boolean"
              },
              "withdraw": {
                "type": "boolean"
              }
            }
          }
        }
      },
      "OpsApprovalPending": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": ["pending_approval"]
          },
          "approval": {
            "$ref": "#/components/schemas/OpsApproval"
          }
        }
      },
      "WoffReason": {
        "type": "string",
        "enum": ["bad_debt", "fraud", "deceased", "bankruptcy", "regulatory"],
        "description": "IFRS 9 write-off reason classification. Maps to ISO 20022 return codes:\nbad_debt/fraud/bankruptcy -> AC06 (BlockedAccount),\ndeceased -> MD07 (EndCustomerDeceased),\nregulatory -> RR04 (RegulatoryReason).\n"
      },
      "BlockedTransaction": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "account_id": {
            "type": "string"
          },
          "direction": {
            "type": "string",
            "enum": ["inbound", "outbound"]
          },
          "counterparty_account": {
            "type": "string",
            "nullable": true
          },
          "attempted_amount": {
            "type": "integer",
            "format": "int64"
          },
          "currency": {
            "type": "string"
          },
          "account_status": {
            "type": "string",
            "enum": ["frozen", "closed", "woff"]
          },
          "error_code": {
            "type": "string",
            "example": "ERR-ACCT-BLOCKED-001"
          },
          "iso_return_code": {
            "type": "string",
            "example": "AC06"
          },
          "channel": {
            "type": "string",
            "example": "api"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "BatchTransferItem": {
        "type": "object",
        "required": ["from_account_id", "to_account_id", "amount", "currency"],
        "properties": {
          "from_account_id": {
            "type": "string",
            "description": "Hex ledger account ID"
          },
          "to_account_id": {
            "type": "string"
          },
          "amount": {
            "type": "string",
            "description": "Amount as string (minor units)"
          },
          "currency": {
            "type": "string"
          },
          "event_type": {
            "type": "string",
            "description": "Transfer type for WOFF whitelist check"
          },
          "tx_id": {
            "type": "string",
            "description": "External transaction ID for pacs.002 tracing"
          }
        }
      },
      "BatchTransferResult": {
        "type": "object",
        "properties": {
          "accepted": {
            "type": "integer",
            "description": "Transfers that passed account guard"
          },
          "rejected": {
            "type": "integer",
            "description": "Transfers blocked by account status"
          },
          "rejections": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "originalTransactionId": {
                  "type": "string"
                },
                "statusReasonCode": {
                  "type": "string",
                  "description": "ISO 20022 StatusReasonCode (AC06, MD07, etc.)"
                },
                "additionalInformation": {
                  "type": "string",
                  "description": "Privacy-safe rejection message"
                }
              }
            }
          }
        }
      },
      "RTransactionResult": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Whether the R-transaction was processed"
          },
          "rTransactionType": {
            "type": "string",
            "enum": ["REJECT", "RETURN", "REFUND", "REVERSAL"],
            "description": "Classified R-transaction type per BR-EF-011"
          },
          "reasonCode": {
            "type": "string",
            "description": "ISO 20022 ExternalStatusReason1Code"
          },
          "originalTransferId": {
            "type": "string",
            "description": "Resolved internal transfer ID"
          },
          "actionTaken": {
            "type": "string",
            "description": "Description of processing action"
          },
          "withinHoldingPeriod": {
            "type": "boolean",
            "description": "Whether original transfer was still in holding period"
          },
          "error": {
            "type": "string",
            "description": "Error message if processing failed"
          }
        }
      },
      "FeeSchedule": {
        "type": "object",
        "description": "One version of a bank's fee schedule for a fee type and currency\n(GoBD: versions are kept). The version in effect at transfer time\nprices it: active, or scheduled with effective_from in the past.\n",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "description": "Human-readable schedule name"
          },
          "transfer_type": {
            "type": "string",
            "description": "Fee type (finance_fee_type): sepa_sct, sepa_inst, sepa_sdd, wire_intl, fx, card_fx, ..."
          },
          "currency": {
            "type": "string",
            "example": "EUR"
          },
          "status": {
            "type": "string",
            "enum": ["active", "scheduled", "inactive", "superseded"]
          },
          "version": {
            "type": "integer"
          },
          "effective_from": {
            "type": "string",
            "format": "date-time"
          },
          "superseded_by": {
            "type": "string",
            "description": "Id of the version that replaced it, or empty"
          },
          "created_by": {
            "type": "string"
          },
          "status_changed_by": {
            "type": "string"
          },
          "status_reason": {
            "type": "string"
          },
          "tiers": {
            "type": "array",
            "nullable": true,
            "items": {
              "$ref": "#/components/schemas/FeeTier"
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CardFxCap": {
        "type": "object",
        "required": ["tenant_id", "cap_minor"],
        "properties": {
          "tenant_id": {
            "type": "string",
            "format": "uuid"
          },
          "cap_minor": {
            "type": "integer",
            "format": "int64",
            "minimum": 0,
            "description": "Largest authorization on a fallback FX rate, minor units of currency",
            "example": 10000
          },
          "currency": {
            "type": "string",
            "example": "EUR"
          }
        }
      },
      "FeeTier": {
        "type": "object",
        "description": "Volume-based pricing tier within a fee schedule. Amounts in minor\nunits of the schedule's currency. The tiers of a schedule start at\n0, each ends where the next starts (`max_amount` exclusive), only\nthe last is open-ended. An amount no tier covers is refused\n(`fee_tier_not_matched`), never priced at 0. For `card_fx`,\n`percentage_fee` applies to the converted card amount.\n",
        "required": ["min_amount", "max_amount"],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "min_amount": {
            "type": "integer",
            "format": "int64",
            "minimum": 0,
            "description": "Lower bound in minor units (inclusive)"
          },
          "max_amount": {
            "type": "integer",
            "format": "int64",
            "nullable": true,
            "description": "Upper bound in minor units (exclusive; null = open-ended, last tier only)"
          },
          "flat_fee": {
            "type": "integer",
            "format": "int64",
            "minimum": 0,
            "description": "Fixed fee in minor units"
          },
          "percentage_fee": {
            "type": "string",
            "description": "Rate in [0, 1) as decimal text, at most six decimals (\"0.017500\" = 1.75 %)",
            "example": "0.002500"
          },
          "min_fee": {
            "type": "integer",
            "format": "int64",
            "minimum": 0,
            "description": "Minimum fee floor in minor units"
          },
          "max_fee": {
            "type": "integer",
            "format": "int64",
            "nullable": true,
            "description": "Maximum fee cap in minor units (null = none; not below min_fee)"
          },
          "sort_order": {
            "type": "integer"
          }
        }
      },
      "FeeOverride": {
        "type": "object",
        "description": "Special pricing of a customer (migration 265): pinned to a fee type\nand currency, valid from / until, ended (never deleted).\n`legacy_all_types`: a row from before 265 that applies to every type.\n",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "customer_id": {
            "type": "string",
            "format": "uuid"
          },
          "fee_schedule_id": {
            "type": "string"
          },
          "transfer_type": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "flat_fee_adj": {
            "type": "integer",
            "format": "int64",
            "description": "Added to the tier's flat fee (negative = discount; the fee never goes below 0)"
          },
          "percentage_override": {
            "type": "string",
            "nullable": true,
            "description": "Replaces the tier rate, [0, 1)"
          },
          "override_reason": {
            "type": "string"
          },
          "admin_id": {
            "type": "string",
            "format": "uuid"
          },
          "created_by": {
            "type": "string"
          },
          "ended_by": {
            "type": "string"
          },
          "end_reason": {
            "type": "string"
          },
          "legacy_all_types": {
            "type": "boolean"
          },
          "state": {
            "type": "string",
            "enum": ["live", "upcoming", "ended"]
          },
          "valid_from": {
            "type": "string",
            "format": "date-time"
          },
          "valid_until": {
            "type": "string",
            "description": "Empty while open-ended"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "FeeCalculation": {
        "type": "object",
        "description": "Fee preview result (charges shown before confirmation). Amounts in\nminor units of the request currency. 0.31.0 (DEC-0038) adds the\ncharge bearer fields and the totals; the fee fields are unchanged.\n",
        "required": [
          "flat_fee",
          "percentage_amount",
          "total_fee",
          "is_override",
          "has_schedule",
          "charge_bearer_options",
          "default_charge_bearer",
          "total_debit",
          "recipient_gets",
          "other_banks_may_deduct"
        ],
        "properties": {
          "schedule_id": {
            "type": "string",
            "format": "uuid",
            "description": "Applied schedule (absent when `has_schedule` is false)"
          },
          "flat_fee": {
            "type": "integer",
            "format": "int64"
          },
          "percentage_amount": {
            "type": "integer",
            "format": "int64",
            "description": "Percentage part, rounded half-up to the minor unit"
          },
          "total_fee": {
            "type": "integer",
            "format": "int64",
            "description": "Our fee as posted (after the tier minimum and maximum; for SWIFT `our`, plus the OUR price when one is configured). 0 without a schedule."
          },
          "is_override": {
            "type": "boolean"
          },
          "has_schedule": {
            "type": "boolean",
            "description": "false when no active schedule prices this type and currency (fee 0)"
          },
          "transfer_type": {
            "type": "string",
            "description": "Fee type of the schedule (absent when `has_schedule` is false)"
          },
          "currency": {
            "$ref": "#/components/schemas/Currency"
          },
          "charge_bearer_options": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": ["slev", "sha", "our"]
            },
            "description": "What the client may offer, default first. `[\"slev\"]` (SEPA, SIC), `[\"sha\"]` or `[\"sha\",\"our\"]` (SWIFT), `[]` (no bearer). Offer a choice only with more than one entry."
          },
          "default_charge_bearer": {
            "type": "string",
            "nullable": true,
            "enum": ["slev", "sha", "our", null],
            "description": "The bearer to send on `POST /api/v1/transfers`; null without one."
          },
          "total_debit": {
            "type": "integer",
            "format": "int64",
            "description": "Debited from the account, `amount` + `total_fee` (SWIFT `ben`, API only, `amount`)"
          },
          "recipient_gets": {
            "type": "integer",
            "format": "int64",
            "description": "Sent to the recipient's side, `amount` (SWIFT `ben`, `amount` - `total_fee`), before any fees other banks take"
          },
          "other_banks_may_deduct": {
            "type": "boolean",
            "description": "SWIFT `sha` or `ben`. The recipient's bank and banks in between may deduct their own fees, so the recipient may get less."
          }
        }
      },
      "FeePreviewRail": {
        "type": "string",
        "enum": [
          "sepa_sct",
          "sepa",
          "sepa_inst",
          "sepa_instant",
          "sic",
          "sic_ip",
          "sic_instant",
          "swift",
          "internal",
          "fps"
        ],
        "description": "Rail of a fee preview. Aliases answer exactly as their rail - `sepa` is `sepa_sct`, `sepa_instant` is `sepa_inst`, `sic_instant` is `sic_ip`. Anything else is 400 `invalid_rail`."
      },
      "CreateFeeScheduleRequest": {
        "type": "object",
        "required": ["tenant_id", "name", "transfer_type", "currency", "tiers"],
        "properties": {
          "tenant_id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "maxLength": 100
          },
          "transfer_type": {
            "type": "string",
            "description": "A fee type of finance_fee_type"
          },
          "currency": {
            "type": "string",
            "example": "EUR",
            "description": "ISO 4217 (no default)"
          },
          "effective_from": {
            "type": "string",
            "format": "date-time",
            "description": "Absent: now; later: a scheduled version"
          },
          "tiers": {
            "description": "The tier table (an array, or the array as a JSON string).",
            "oneOf": [
              {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/FeeTier"
                }
              },
              {
                "type": "string"
              }
            ]
          }
        }
      },
      "CreateFeeOverrideRequest": {
        "type": "object",
        "required": [
          "customer_id",
          "transfer_type",
          "currency",
          "override_reason"
        ],
        "properties": {
          "customer_id": {
            "type": "string",
            "format": "uuid"
          },
          "transfer_type": {
            "type": "string"
          },
          "currency": {
            "type": "string",
            "example": "EUR"
          },
          "flat_fee_adj": {
            "type": "integer",
            "format": "int64",
            "description": "Minor units",
            "may be negative": null
          },
          "percentage_override": {
            "type": "string",
            "nullable": true,
            "description": "[0, 1), at most six decimals"
          },
          "override_reason": {
            "type": "string",
            "minLength": 3,
            "maxLength": 1000
          },
          "valid_from": {
            "type": "string",
            "format": "date-time"
          },
          "valid_until": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "ClosurePolicyContact": {
        "type": "object",
        "required": ["email", "role"],
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 100,
            "nullable": true
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "role": {
            "type": "string",
            "enum": ["staff", "compliance"]
          }
        }
      },
      "ClosurePolicy": {
        "type": "object",
        "description": "Account termination rules of a bank (closure_policy): versioned,\nimmutable but for the status (draft -> active -> archived), one\nactive version per bank. `platform_default`: the platform's\nfallback (read-only for a bank).\n",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "tenant_id": {
            "type": "string",
            "nullable": true
          },
          "version": {
            "type": "integer"
          },
          "notice_period_days": {
            "type": "integer",
            "minimum": 0,
            "maximum": 730
          },
          "aml_notice_period_days": {
            "type": "integer",
            "minimum": 0
          },
          "reason_categories": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "escalation_contacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClosurePolicyContact"
            }
          },
          "regulatory_framework": {
            "type": "string",
            "enum": [
              "psd2_eu",
              "bgb_de",
              "fca_uk",
              "bai_pt",
              "es_es",
              "ch_or",
              "custom"
            ]
          },
          "status": {
            "type": "string",
            "enum": ["draft", "active", "archived"]
          },
          "created_by": {
            "type": "string"
          },
          "created_at": {
            "type": "string"
          },
          "activated_by": {
            "type": "string",
            "nullable": true
          },
          "activated_at": {
            "type": "string",
            "nullable": true
          },
          "archived_by": {
            "type": "string",
            "nullable": true
          },
          "archived_at": {
            "type": "string",
            "nullable": true
          },
          "platform_default": {
            "type": "boolean"
          }
        }
      },
      "CreateClosurePolicyRequest": {
        "type": "object",
        "properties": {
          "notice_period_days": {
            "type": "integer",
            "minimum": 0,
            "maximum": 730,
            "default": 62
          },
          "aml_notice_period_days": {
            "type": "integer",
            "minimum": 0,
            "default": 0
          },
          "reason_categories": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "aml_derisking",
                "aml_pep_risk",
                "fraud_suspicion",
                "sanctions_match",
                "inactivity",
                "terms_violation",
                "regulatory_requirement",
                "business_decision",
                "customer_request"
              ]
            }
          },
          "escalation_contacts": {
            "type": "array",
            "maxItems": 10,
            "items": {
              "$ref": "#/components/schemas/ClosurePolicyContact"
            }
          },
          "regulatory_framework": {
            "type": "string",
            "enum": [
              "psd2_eu",
              "bgb_de",
              "fca_uk",
              "bai_pt",
              "es_es",
              "ch_or",
              "custom"
            ]
          }
        }
      },
      "DepositCapStatus": {
        "type": "object",
        "properties": {
          "licence_pack": {
            "type": "string"
          },
          "deposit_cap_minor": {
            "type": ["integer", "null"],
            "format": "int64",
            "description": "The pack's cap in CHF minor; null without a cap"
          },
          "utilisation_chf_minor": {
            "type": ["integer", "null"],
            "format": "int64",
            "description": "Deposits held (customer e-money and held credits) in CHF minor; null when unknown or not convertible"
          },
          "utilisation_status": {
            "type": "string",
            "enum": ["ok", "unknown"]
          },
          "intake_blocked": {
            "type": "boolean"
          },
          "safeguarding_emoney_chf_minor": {
            "type": ["integer", "null"],
            "format": "int64"
          },
          "safeguarding_accounts_chf_minor": {
            "type": ["integer", "null"],
            "format": "int64"
          },
          "safeguarding_status": {
            "type": "string",
            "enum": ["ok", "none", "unknown"]
          },
          "safeguarding_match": {
            "type": ["boolean", "null"],
            "description": "Safeguarded at least the customer funds in every currency"
          },
          "safeguarding_shortfall_chf_minor": {
            "type": ["integer", "null"],
            "format": "int64"
          },
          "safeguarding_by_currency": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "currency": {
                  "type": "string"
                },
                "customer_funds_minor": {
                  "type": "integer",
                  "format": "int64"
                },
                "safeguarded_minor": {
                  "type": "integer",
                  "format": "int64"
                },
                "shortfall_minor": {
                  "type": "integer",
                  "format": "int64"
                }
              }
            }
          },
          "reporting_currency": {
            "type": "string",
            "description": "The bank's reporting currency (CHF for a Swiss bank, EUR in the euro area)"
          },
          "safeguarding_emoney_minor": {
            "type": ["integer", "null"],
            "format": "int64",
            "description": "Customer funds in the reporting currency"
          },
          "safeguarding_accounts_minor": {
            "type": ["integer", "null"],
            "format": "int64",
            "description": "Safeguarded balance in the reporting currency"
          },
          "safeguarding_shortfall_minor": {
            "type": ["integer", "null"],
            "format": "int64",
            "description": "Customer funds not covered in the reporting currency (0 when covered)"
          },
          "chf_rate_live": {
            "type": "boolean",
            "description": "The report's CHF rate is live (a provider feed or an override); false: a static value, which the cap's own decisions refuse"
          },
          "chf_rate_from": {
            "type": "string",
            "enum": ["live_row", "static_row", "static_table", "none"],
            "description": "Where the report's CHF rate came from; none: the report took no CHF rate"
          }
        }
      },
      "WoffSummary": {
        "type": "object",
        "properties": {
          "total_accounts": {
            "type": "integer"
          },
          "by_currency": {
            "type": "array",
            "description": "One row per currency; amounts in its minor units",
            "items": {
              "type": "object",
              "properties": {
                "currency": {
                  "type": "string"
                },
                "accounts": {
                  "type": "integer"
                },
                "woff_amount": {
                  "type": "integer",
                  "format": "int64"
                },
                "recovered": {
                  "type": "integer",
                  "format": "int64"
                },
                "outstanding": {
                  "type": "integer",
                  "format": "int64",
                  "description": "Written off and not recovered"
                },
                "recovery_rate_pct": {
                  "type": "number",
                  "description": "Recovered over written off: percent, 2 decimals"
                }
              }
            }
          },
          "by_reason": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "reason": {
                  "type": "string"
                },
                "currency": {
                  "type": "string"
                },
                "count": {
                  "type": "integer"
                },
                "amount": {
                  "type": "integer",
                  "format": "int64"
                },
                "recovered": {
                  "type": "integer",
                  "format": "int64"
                }
              }
            }
          },
          "blocked_last_30d": {
            "type": "integer",
            "description": "Payments blocked on these accounts in the last 30 days"
          }
        }
      },
      "WoffAccountList": {
        "type": "object",
        "properties": {
          "accounts": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "account_id": {
                  "type": "string"
                },
                "tenant_id": {
                  "type": "string",
                  "format": "uuid"
                },
                "tenant_name": {
                  "type": "string"
                },
                "customer_id": {
                  "type": ["string", "null"],
                  "format": "uuid"
                },
                "customer_name": {
                  "type": ["string", "null"]
                },
                "name": {
                  "type": "string"
                },
                "woff_reason": {
                  "type": "string"
                },
                "woff_date": {
                  "type": "string",
                  "format": "date-time"
                },
                "woff_amount": {
                  "type": "integer",
                  "format": "int64"
                },
                "recovery_total": {
                  "type": "integer",
                  "format": "int64"
                },
                "outstanding": {
                  "type": "integer",
                  "format": "int64",
                  "description": "Written off and not recovered"
                },
                "iso_return_code": {
                  "type": "string"
                },
                "currency": {
                  "type": "string"
                }
              }
            }
          },
          "total": {
            "type": "integer",
            "description": "Every written-off account of the tenant in the period"
          },
          "limit": {
            "type": "integer"
          },
          "offset": {
            "type": "integer"
          }
        }
      },
      "CreateCashDepositRequest": {
        "type": "object",
        "required": ["customer_id", "wallet_id", "tenant_id", "amount"],
        "properties": {
          "customer_id": {
            "type": "string",
            "format": "uuid"
          },
          "wallet_id": {
            "type": "string",
            "format": "uuid"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid"
          },
          "amount": {
            "type": "integer",
            "minimum": 1,
            "description": "Amount in minor units (cents)"
          },
          "currency": {
            "type": "string",
            "default": "EUR",
            "minLength": 3,
            "maxLength": 3
          },
          "source_of_funds": {
            "type": "string",
            "enum": [
              "salary",
              "savings",
              "business_income",
              "gift",
              "inheritance",
              "sale_of_property",
              "loan",
              "other"
            ]
          },
          "source_of_funds_detail": {
            "type": "string"
          },
          "depositor_type": {
            "type": "string",
            "enum": ["account_holder", "third_party"],
            "default": "account_holder"
          },
          "depositor_name": {
            "type": "string"
          },
          "depositor_id_type": {
            "type": "string",
            "enum": [
              "passport",
              "id_card",
              "drivers_license",
              "residence_permit"
            ]
          },
          "depositor_id_number": {
            "type": "string"
          },
          "branch_id": {
            "type": "string"
          },
          "receipt_number": {
            "type": "string"
          },
          "teller_notes": {
            "type": "string"
          },
          "processed_by": {
            "type": "string",
            "description": "Service calls only (required there): admin user ID of the processing teller. For an admin session the teller is the session's (DEC-0043) and this field is ignored"
          }
        }
      },
      "CashDepositCreateResult": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "compliance_status": {
            "type": "string",
            "enum": [
              "pending",
              "auto_approved",
              "flagged",
              "approved",
              "rejected"
            ]
          },
          "daily_aggregate": {
            "type": "integer",
            "description": "The customer's cash of the day in the deposit's currency (minor units)"
          },
          "daily_aggregate_eur": {
            "type": "integer",
            "description": "The customer's cash of the day in every currency",
            "EUR cents at the reference rate (what the threshold compares)": null
          },
          "cash_threshold_eur": {
            "type": "integer",
            "description": "The bank's daily cash threshold",
            "EUR cents": null
          },
          "compliance_flags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "amount": {
            "type": "integer"
          },
          "needs_approval": {
            "type": "boolean"
          }
        }
      },
      "CashDeposit": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "transfer_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "customer_id": {
            "type": "string",
            "format": "uuid"
          },
          "wallet_id": {
            "type": "string",
            "format": "uuid"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid"
          },
          "amount": {
            "type": "integer"
          },
          "currency": {
            "type": "string"
          },
          "source_of_funds": {
            "type": "string",
            "nullable": true
          },
          "source_of_funds_detail": {
            "type": "string"
          },
          "depositor_type": {
            "type": "string"
          },
          "depositor_name": {
            "type": "string"
          },
          "depositor_id_type": {
            "type": "string",
            "nullable": true
          },
          "depositor_id_number": {
            "type": "string"
          },
          "branch_id": {
            "type": "string"
          },
          "receipt_number": {
            "type": "string"
          },
          "teller_notes": {
            "type": "string"
          },
          "compliance_status": {
            "type": "string"
          },
          "compliance_flags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "rejection_reason": {
            "type": "string"
          },
          "approved_by": {
            "type": "string",
            "nullable": true
          },
          "approved_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "rejected_by": {
            "type": "string",
            "nullable": true
          },
          "daily_aggregate": {
            "type": "integer"
          },
          "daily_aggregate_eur": {
            "type": "integer",
            "nullable": true,
            "description": "EUR cents of the day the threshold saw (null before migration 268)"
          },
          "amount_eur": {
            "type": "integer",
            "nullable": true,
            "description": "EUR cents of this deposit at the reference rate (null before migration 268)"
          },
          "processed_by": {
            "type": "string"
          },
          "customer_name": {
            "type": "string"
          },
          "wallet_name": {
            "type": ["string", "null"],
            "description": "Name of the credited account."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CashDepositList": {
        "type": "object",
        "properties": {
          "deposits": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CashDeposit"
            }
          },
          "total": {
            "type": "integer"
          }
        }
      },
      "CashDepositDailyAggregate": {
        "type": "object",
        "properties": {
          "customer_id": {
            "type": "string",
            "format": "uuid"
          },
          "currency": {
            "type": "string",
            "enum": ["EUR"]
          },
          "daily_aggregate": {
            "type": "integer",
            "description": "Total deposited today in every currency",
            "EUR cents at the reference rate": null
          },
          "threshold": {
            "type": "integer",
            "description": "The bank's daily cash threshold in EUR cents (jurisdiction profile; default 1000000 = 10000 EUR)"
          },
          "single_review_threshold": {
            "type": "integer",
            "description": "One deposit at or above it (EUR cents) is flagged for a suspicion check (jurisdiction profile; default 1500000)."
          },
          "remaining_under_threshold": {
            "type": "integer"
          },
          "threshold_exceeded": {
            "type": "boolean"
          },
          "amount_eur": {
            "type": "integer",
            "description": "With `amount`, its EUR cents at the reference rate."
          },
          "daily_aggregate_after": {
            "type": "integer",
            "description": "With `amount`, the day's total including it (EUR cents)."
          },
          "needs_approval": {
            "type": "boolean",
            "description": "With `amount`, whether recording it now waits for a second officer (the same assessment as POST /cash-deposits)."
          },
          "source_of_funds_required": {
            "type": "boolean",
            "description": "With `amount`, the source of funds is required."
          },
          "flags": {
            "type": "array",
            "description": "With `amount`, the checks it would raise.",
            "items": {
              "type": "string",
              "enum": [
                "threshold_exceeded",
                "sar_required",
                "structuring_suspected"
              ]
            }
          }
        }
      },
      "InsightsParams": {
        "type": "object",
        "description": "Translation params. Amounts are minor units with a `currency` param.",
        "additionalProperties": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "integer",
              "format": "int64"
            }
          ]
        }
      },
      "InsightsSummary": {
        "type": "object",
        "required": ["method", "month", "currencies"],
        "properties": {
          "method": {
            "type": "string",
            "example": "rules_v1"
          },
          "month": {
            "type": "string",
            "example": "2026-09"
          },
          "account_id": {
            "type": "string",
            "nullable": true
          },
          "currencies": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "currency",
                "spent_minor",
                "received_minor",
                "usual_minor",
                "usual_months",
                "by_category",
                "by_merchant"
              ],
              "properties": {
                "currency": {
                  "type": "string",
                  "example": "EUR"
                },
                "spent_minor": {
                  "type": "integer",
                  "format": "int64"
                },
                "received_minor": {
                  "type": "integer",
                  "format": "int64"
                },
                "usual_minor": {
                  "type": "integer",
                  "format": "int64",
                  "nullable": true
                },
                "usual_months": {
                  "type": "integer"
                },
                "by_category": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "category": {
                        "type": "string",
                        "enum": [
                          "groceries",
                          "dining",
                          "transport",
                          "travel",
                          "shopping",
                          "subscriptions",
                          "utilities",
                          "health",
                          "entertainment",
                          "cash",
                          "fees",
                          "rent",
                          "transfers",
                          "salary",
                          "income",
                          "own_transfer",
                          "fx",
                          "other"
                        ]
                      },
                      "amount_minor": {
                        "type": "integer",
                        "format": "int64"
                      },
                      "count": {
                        "type": "integer"
                      }
                    }
                  }
                },
                "by_merchant": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "merchant": {
                        "type": "string"
                      },
                      "merchant_key": {
                        "type": "string",
                        "description": "Bank fees (`fee_*` postings) group under the one key\n`bank_fees` (merchant `Bank fees`, category `fees`);\nthe phone names that row from the key.\n"
                      },
                      "category": {
                        "type": "string"
                      },
                      "amount_minor": {
                        "type": "integer",
                        "format": "int64"
                      },
                      "count": {
                        "type": "integer"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "InsightsSeries": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "r_4dd925f4679ddbd4"
          },
          "merchant": {
            "type": "string"
          },
          "merchant_key": {
            "type": "string"
          },
          "direction": {
            "type": "string",
            "enum": ["out", "in"]
          },
          "source": {
            "type": "string",
            "enum": ["card", "transfer"]
          },
          "category": {
            "type": "string"
          },
          "cadence": {
            "type": "string",
            "enum": ["weekly", "biweekly", "monthly", "quarterly", "yearly"]
          },
          "interval_days": {
            "type": "integer"
          },
          "typical_minor": {
            "type": "integer",
            "format": "int64"
          },
          "currency": {
            "type": "string"
          },
          "last_date": {
            "type": "string",
            "format": "date"
          },
          "next_date": {
            "type": "string",
            "format": "date"
          },
          "last_amounts_minor": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int64"
            }
          },
          "occurrences": {
            "type": "integer"
          },
          "confidence": {
            "type": "string",
            "enum": ["high", "medium"]
          },
          "amount_changed": {
            "type": "boolean"
          },
          "active": {
            "type": "boolean"
          },
          "transaction_ids": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "InsightsForecast": {
        "type": "object",
        "required": ["method", "status", "account_id", "currency"],
        "properties": {
          "method": {
            "type": "string",
            "example": "rules_v1"
          },
          "status": {
            "type": "string",
            "enum": ["ok", "not_enough_history"]
          },
          "account_id": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "as_of": {
            "type": "string",
            "format": "date"
          },
          "horizon_date": {
            "type": "string",
            "format": "date"
          },
          "history_days": {
            "type": "integer"
          },
          "min_history_days": {
            "type": "integer",
            "example": 60
          },
          "balance_now_minor": {
            "type": "integer",
            "format": "int64"
          },
          "balance_minor": {
            "type": "integer",
            "format": "int64",
            "nullable": true
          },
          "low_minor": {
            "type": "integer",
            "format": "int64",
            "nullable": true
          },
          "high_minor": {
            "type": "integer",
            "format": "int64",
            "nullable": true
          },
          "daily_spend_minor": {
            "type": "integer",
            "format": "int64"
          },
          "days_left": {
            "type": "integer"
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "enum": ["recurring", "salary", "discretionary"]
                },
                "label": {
                  "type": "string"
                },
                "amount_minor": {
                  "type": "integer",
                  "format": "int64",
                  "description": "Signed; bills and spend negative"
                },
                "date": {
                  "type": "string",
                  "format": "date"
                }
              }
            }
          }
        }
      },
      "InsightsNote": {
        "type": "object",
        "required": [
          "id",
          "kind",
          "severity",
          "title_key",
          "reason",
          "params",
          "transaction_ids"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "duplicate_charge",
              "price_rise",
              "unusual_charge",
              "card_testing",
              "new_country_night",
              "velocity"
            ]
          },
          "severity": {
            "type": "string",
            "enum": ["warning", "info"]
          },
          "title_key": {
            "type": "string",
            "example": "insights.note.duplicate_charge"
          },
          "reason": {
            "type": "string",
            "example": "insights.note.duplicate_charge.reason"
          },
          "date": {
            "type": "string",
            "format": "date",
            "description": "Local day; also sent as params.date"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "params": {
            "$ref": "#/components/schemas/InsightsParams"
          },
          "transaction_ids": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "required": ["error"],
        "properties": {
          "error": {
            "type": "string"
          }
        }
      },
      "ScaChallenge": {
        "type": "object",
        "description": "A challenge identity-api created on the customer's bound phone (0.34.0). The phone shows the amount and payee; for a web request the customer picks `number` there.",
        "required": ["id", "kind", "expires_in", "methods"],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "kind": {
            "type": "string",
            "enum": ["payment", "card_action", "account_change"]
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "expires_in": {
            "type": "integer",
            "description": "Seconds"
          },
          "number": {
            "type": "integer",
            "nullable": true,
            "description": "10-99: shown by the web client, picked on the phone; null for a request from the bound phone itself"
          },
          "methods": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": ["device", "totp"]
            }
          },
          "device_label": {
            "type": "string",
            "nullable": true
          },
          "active_from": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "ScaError": {
        "type": "object",
        "description": "The SCA answers of a customer payment or card write (0.34.0). Clients match `error`.",
        "required": ["error"],
        "properties": {
          "error": {
            "type": "string",
            "enum": ["SCA required", "Invalid SCA token"]
          },
          "code": {
            "type": "string",
            "enum": [
              "sca_required",
              "sca_setup_required",
              "sca_device_locked",
              "sca_token_invalid",
              "sca_token_expired",
              "sca_token_used",
              "sca_intent_mismatch",
              "sca_wrong_kind",
              "sca_wrong_customer"
            ]
          },
          "reason": {
            "type": "string",
            "description": "Text, or with `sca_device_locked` the cause, `locked` or `recently_removed`."
          },
          "until": {
            "type": "string",
            "format": "date-time",
            "description": "With `sca_device_locked`, the end of the lock or of the 24 h after the removal (absent for a lock until recovery)."
          },
          "challenge": {
            "$ref": "#/components/schemas/ScaChallenge"
          },
          "active_from": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "TenantScaPolicy": {
        "type": "object",
        "description": "A tenant's SCA policy with every default filled in (0.34.0).",
        "required": [
          "tenant_id",
          "effective_mode",
          "sca_device_approval",
          "grace_until",
          "bind_cooling_secs",
          "deny_block_secs",
          "challenge_ttl_secs",
          "low_value",
          "own_account_exempt",
          "require_android_attestation",
          "min_app_build"
        ],
        "properties": {
          "tenant_id": {
            "type": "string",
            "format": "uuid"
          },
          "effective_mode": {
            "type": "string",
            "enum": ["off", "optional", "required"],
            "description": "What the gate applies now; `optional` with a passed `grace_until` is `required`"
          },
          "sca_device_approval": {
            "type": "string",
            "enum": ["off", "optional", "required"],
            "description": "`off`: the caller's own access token as `X-SCA-Token`; `optional`: approval on the bound phone, the access token without one; `required`: approval on the bound phone (or TOTP)"
          },
          "grace_until": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "UTC, `YYYY-MM-DDTHH:MM:SSZ`. From then on `optional` is `required`"
          },
          "bind_cooling_secs": {
            "type": "integer",
            "minimum": 3600,
            "maximum": 604800,
            "description": "A newly bound phone approves payments after this, 3600 to 604800 s (default 14400; identity-api's floor is an hour)"
          },
          "deny_block_secs": {
            "type": "integer",
            "minimum": 60,
            "maximum": 86400,
            "description": "After Not me, web challenges are blocked this long, 60 to 86400 s (default 900)"
          },
          "challenge_ttl_secs": {
            "type": "integer",
            "minimum": 30,
            "maximum": 300,
            "description": "Lifetime of a challenge, 30 to 300 s (default 60)"
          },
          "low_value": {
            "type": "object",
            "required": [
              "enabled",
              "max_eur_minor",
              "cum_eur_minor",
              "max_count"
            ],
            "properties": {
              "enabled": {
                "type": "boolean",
                "description": "Default false"
              },
              "max_eur_minor": {
                "type": "integer",
                "minimum": 0,
                "maximum": 3000,
                "description": "Per payment, EUR equivalent in cents (default 3000; 0: no payment is exempt)"
              },
              "cum_eur_minor": {
                "type": "integer",
                "minimum": 0,
                "maximum": 10000,
                "description": "Since the last SCA, this payment included (default 10000)"
              },
              "max_count": {
                "type": "integer",
                "minimum": 0,
                "maximum": 5,
                "description": "Payments since the last SCA, this one included (default 5)"
              }
            }
          },
          "own_account_exempt": {
            "type": "boolean",
            "description": "Transfers between the caller's own accounts (internal rail) need no SCA (default true)"
          },
          "require_android_attestation": {
            "type": "boolean",
            "description": "identity-api binds an Android phone only with hardware key attestation (default true)"
          },
          "min_app_build": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000000,
            "description": "The oldest app build that may sign in, 0 to 1000000 (default 0: no minimum; migration 255). At least 15 while the setting is not off"
          }
        }
      },
      "TenantScaPolicyPatch": {
        "type": "object",
        "description": "Any members of TenantScaPolicy except `tenant_id` and `effective_mode`; at least one. `low_value` may name some of its members.",
        "minProperties": 1,
        "additionalProperties": false,
        "properties": {
          "sca_device_approval": {
            "type": "string",
            "enum": ["off", "optional", "required"]
          },
          "grace_until": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "RFC 3339 (any offset; stored as UTC) or null"
          },
          "bind_cooling_secs": {
            "type": "integer",
            "minimum": 3600,
            "maximum": 604800
          },
          "deny_block_secs": {
            "type": "integer",
            "minimum": 60,
            "maximum": 86400
          },
          "challenge_ttl_secs": {
            "type": "integer",
            "minimum": 30,
            "maximum": 300
          },
          "low_value": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "enabled": {
                "type": "boolean"
              },
              "max_eur_minor": {
                "type": "integer",
                "minimum": 0,
                "maximum": 3000
              },
              "cum_eur_minor": {
                "type": "integer",
                "minimum": 0,
                "maximum": 10000
              },
              "max_count": {
                "type": "integer",
                "minimum": 0,
                "maximum": 5
              }
            }
          },
          "own_account_exempt": {
            "type": "boolean"
          },
          "require_android_attestation": {
            "type": "boolean"
          },
          "min_app_build": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000000
          }
        }
      },
      "TenantFeatureKey": {
        "type": "string",
        "enum": [
          "sepa_sct",
          "sepa_instant",
          "sepa_dd",
          "swift",
          "sic",
          "sic_ip",
          "cards",
          "fx",
          "webhooks",
          "assistant",
          "support_chat",
          "support_ai",
          "support_tickets"
        ]
      },
      "DocumentRetentionSetting": {
        "type": "object",
        "description": "One document retention setting of a tenant (ARCH-030 \u00a73.3), in years after the business relationship ends.",
        "required": [
          "tenant",
          "platform_default",
          "effective",
          "minimum",
          "maximum",
          "basis"
        ],
        "properties": {
          "tenant": {
            "type": "integer",
            "nullable": true,
            "description": "The tenant's override; null: the platform default."
          },
          "platform_default": {
            "type": "integer"
          },
          "effective": {
            "type": "integer",
            "description": "The override, else the platform default, never below the minimum."
          },
          "minimum": {
            "type": "integer"
          },
          "maximum": {
            "type": "integer"
          },
          "basis": {
            "type": "string",
            "description": "The legal source of the minimum (the jurisdiction profile's, else the platform's)."
          }
        }
      },
      "TenantDocumentRetention": {
        "type": "object",
        "required": [
          "tenant_id",
          "cdd_documents_years",
          "customer_letters_years"
        ],
        "properties": {
          "tenant_id": {
            "type": "string",
            "format": "uuid"
          },
          "cdd_documents_years": {
            "$ref": "#/components/schemas/DocumentRetentionSetting"
          },
          "customer_letters_years": {
            "$ref": "#/components/schemas/DocumentRetentionSetting"
          }
        }
      },
      "TenantDocumentRetentionPatch": {
        "type": "object",
        "minProperties": 1,
        "properties": {
          "cdd_documents_years": {
            "type": "integer",
            "nullable": true
          },
          "customer_letters_years": {
            "type": "integer",
            "nullable": true
          }
        }
      },
      "PlatformDocumentRetentionDefault": {
        "type": "object",
        "required": ["value", "minimum", "maximum", "basis"],
        "properties": {
          "value": {
            "type": "integer"
          },
          "minimum": {
            "type": "integer"
          },
          "maximum": {
            "type": "integer"
          },
          "basis": {
            "type": "string"
          }
        }
      },
      "AiPolicyMembers": {
        "type": "object",
        "description": "A policy of the support AI (ARCH-029a \u00a711.5, DEC-0034).",
        "required": [
          "scope",
          "blocked",
          "handoff_always",
          "tools",
          "actions",
          "locales",
          "profiles",
          "zdr_required",
          "trace_retention_days",
          "monthly_token_cap",
          "turns_per_customer_hour",
          "human_review_pct"
        ],
        "properties": {
          "scope": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AiPolicyScope"
            }
          },
          "blocked": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AiPolicyTopic"
            }
          },
          "handoff_always": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AiPolicyScope"
            }
          },
          "tools": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AiPolicyTool"
            }
          },
          "actions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportActionKind"
            }
          },
          "locales": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": ["en", "es", "de", "pt", "ar", "ca"]
            }
          },
          "profiles": {
            "type": "object",
            "required": ["chat", "utility", "moderation"],
            "properties": {
              "chat": {
                "$ref": "#/components/schemas/AiPolicyProfile"
              },
              "utility": {
                "$ref": "#/components/schemas/AiPolicyProfile"
              },
              "moderation": {
                "$ref": "#/components/schemas/AiPolicyProfile"
              }
            }
          },
          "zdr_required": {
            "type": "boolean"
          },
          "trace_retention_days": {
            "type": "integer",
            "minimum": 1,
            "maximum": 90
          },
          "monthly_token_cap": {
            "type": "integer",
            "format": "int64",
            "minimum": 0,
            "nullable": true
          },
          "turns_per_customer_hour": {
            "type": "integer",
            "minimum": 1,
            "maximum": 600
          },
          "human_review_pct": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100
          }
        }
      },
      "AiPolicyScope": {
        "type": "string",
        "enum": [
          "accounts",
          "payments",
          "cards",
          "fees",
          "statements",
          "product_howto",
          "bank_requests",
          "complaint_routing"
        ]
      },
      "AiPolicyTopic": {
        "type": "string",
        "description": "Refused with the fixed sentence of its reason: general_knowledge, coding -> out_of_scope; investment, tax, legal, credit_decisions -> advice_not_offered; other_persons -> other_person.",
        "enum": [
          "general_knowledge",
          "coding",
          "investment",
          "tax",
          "legal",
          "credit_decisions",
          "other_persons"
        ]
      },
      "AiPolicyTool": {
        "type": "string",
        "enum": [
          "account_balances",
          "spending_summary",
          "recent_transactions",
          "transaction_detail",
          "card_status",
          "fees_explained",
          "statement_link",
          "search_help"
        ]
      },
      "AiPolicyProfile": {
        "type": "string",
        "enum": ["eu_api_test", "self_hosted_prod"]
      },
      "AiPolicyDraftInput": {
        "allOf": [
          {
            "$ref": "#/components/schemas/AiPolicyMembers"
          },
          {
            "type": "object",
            "required": ["reason"],
            "properties": {
              "reason": {
                "type": "string",
                "minLength": 1,
                "maxLength": 500
              }
            }
          }
        ]
      },
      "AiPolicyDecisionInput": {
        "type": "object",
        "properties": {
          "reason": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          }
        }
      },
      "AiPolicyVersion": {
        "type": "object",
        "required": [
          "id",
          "version",
          "status",
          "policy",
          "reason",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "version": {
            "type": "integer",
            "minimum": 1
          },
          "status": {
            "type": "string",
            "enum": ["draft", "active", "superseded", "rejected"]
          },
          "base_version": {
            "type": "integer",
            "nullable": true
          },
          "policy": {
            "$ref": "#/components/schemas/AiPolicyMembers"
          },
          "reason": {
            "type": "string"
          },
          "created_by": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "decided_by": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "decided_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "decision_reason": {
            "type": "string",
            "nullable": true
          },
          "activated_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "AiPolicyKill": {
        "type": "object",
        "required": ["kill"],
        "properties": {
          "kill": {
            "type": "boolean"
          },
          "reason": {
            "type": "string",
            "nullable": true
          },
          "updated_by": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "clear_request": {
            "type": "object",
            "nullable": true,
            "description": "A pending request to clear the kill switch (four-eyes).",
            "properties": {
              "requested_by": {
                "type": "string",
                "format": "uuid"
              },
              "requested_at": {
                "type": "string",
                "format": "date-time"
              },
              "reason": {
                "type": "string",
                "nullable": true
              }
            }
          },
          "step": {
            "type": "string",
            "enum": ["set", "unchanged", "clear_requested", "cleared"]
          }
        }
      },
      "AiPolicyVocabulary": {
        "type": "object",
        "properties": {
          "scope": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "blocked": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "tools": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "actions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "locales": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "profiles": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "refusal_reasons": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "mandatory_handoffs": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "AiPolicyOverview": {
        "type": "object",
        "required": ["active", "drafts", "history", "kill", "vocabulary"],
        "properties": {
          "active": {
            "allOf": [
              {
                "$ref": "#/components/schemas/AiPolicyVersion"
              }
            ],
            "nullable": true
          },
          "drafts": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "version": {
                  "$ref": "#/components/schemas/AiPolicyVersion"
                },
                "diff": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "object",
                    "properties": {
                      "old": {},
                      "new": {}
                    }
                  }
                },
                "stale": {
                  "type": "boolean"
                }
              }
            }
          },
          "history": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AiPolicyVersion"
            }
          },
          "kill": {
            "$ref": "#/components/schemas/AiPolicyKill"
          },
          "viewer_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "vocabulary": {
            "$ref": "#/components/schemas/AiPolicyVocabulary"
          }
        }
      },
      "AiPolicyOverridePatch": {
        "type": "object",
        "description": "Members of one override layer; null follows the platform. `kill` (platform layer only), `extra_handoff_triggers` (bank layer only), optional `reason`.",
        "properties": {
          "scope": {
            "type": "array",
            "nullable": true,
            "items": {
              "$ref": "#/components/schemas/AiPolicyScope"
            }
          },
          "blocked": {
            "type": "array",
            "nullable": true,
            "items": {
              "$ref": "#/components/schemas/AiPolicyTopic"
            }
          },
          "handoff_always": {
            "type": "array",
            "nullable": true,
            "items": {
              "$ref": "#/components/schemas/AiPolicyScope"
            }
          },
          "tools": {
            "type": "array",
            "nullable": true,
            "items": {
              "$ref": "#/components/schemas/AiPolicyTool"
            }
          },
          "actions": {
            "type": "array",
            "nullable": true,
            "items": {
              "$ref": "#/components/schemas/SupportActionKind"
            }
          },
          "locales": {
            "type": "array",
            "nullable": true,
            "items": {
              "type": "string",
              "enum": ["en", "es", "de", "pt", "ar", "ca"]
            }
          },
          "profile_chat": {
            "allOf": [
              {
                "$ref": "#/components/schemas/AiPolicyProfile"
              }
            ],
            "nullable": true
          },
          "profile_utility": {
            "allOf": [
              {
                "$ref": "#/components/schemas/AiPolicyProfile"
              }
            ],
            "nullable": true
          },
          "profile_moderation": {
            "allOf": [
              {
                "$ref": "#/components/schemas/AiPolicyProfile"
              }
            ],
            "nullable": true
          },
          "zdr_required": {
            "type": "boolean",
            "nullable": true
          },
          "trace_retention_days": {
            "type": "integer",
            "minimum": 1,
            "maximum": 90,
            "nullable": true
          },
          "monthly_token_cap": {
            "type": "integer",
            "format": "int64",
            "minimum": 0,
            "nullable": true
          },
          "turns_per_customer_hour": {
            "type": "integer",
            "minimum": 1,
            "maximum": 600,
            "nullable": true
          },
          "human_review_pct": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100,
            "nullable": true
          },
          "kill": {
            "type": "boolean"
          },
          "kill_clear_requested_by": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "readOnly": true
          },
          "kill_clear_reason": {
            "type": "string",
            "nullable": true,
            "readOnly": true
          },
          "extra_handoff_triggers": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "type": "object",
              "required": ["locale", "phrase"],
              "properties": {
                "locale": {
                  "type": "string",
                  "enum": ["en", "es", "de", "pt", "ar"]
                },
                "phrase": {
                  "type": "string",
                  "minLength": 2,
                  "maxLength": 80
                }
              }
            }
          },
          "reason": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          }
        }
      },
      "TenantAiPolicy": {
        "type": "object",
        "required": [
          "tenant_id",
          "version",
          "hash",
          "kill",
          "effective",
          "platform",
          "layers",
          "can",
          "vocabulary"
        ],
        "properties": {
          "tenant_id": {
            "type": "string",
            "format": "uuid"
          },
          "version": {
            "type": "integer",
            "description": "The active platform version (0: none, the AI is stopped)."
          },
          "hash": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "kill": {
            "type": "object",
            "properties": {
              "effective": {
                "type": "boolean"
              },
              "platform": {
                "type": "boolean"
              },
              "tenant": {
                "type": "boolean"
              },
              "reason": {
                "type": "string",
                "nullable": true
              },
              "clear_requested_by": {
                "type": "string",
                "format": "uuid",
                "nullable": true
              }
            }
          },
          "effective": {
            "$ref": "#/components/schemas/AiPolicyMembers"
          },
          "platform": {
            "$ref": "#/components/schemas/AiPolicyMembers"
          },
          "layers": {
            "type": "object",
            "properties": {
              "platform": {
                "$ref": "#/components/schemas/AiPolicyOverridePatch"
              },
              "bank": {
                "$ref": "#/components/schemas/AiPolicyOverridePatch"
              }
            }
          },
          "can": {
            "type": "object",
            "properties": {
              "layer": {
                "type": "string",
                "enum": ["platform", "bank"],
                "nullable": true
              },
              "kill": {
                "type": "boolean"
              }
            }
          },
          "vocabulary": {
            "$ref": "#/components/schemas/AiPolicyVocabulary"
          }
        }
      },
      "AiPolicyChanges": {
        "type": "object",
        "required": ["changes"],
        "properties": {
          "changes": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "tenant_id": {
                  "type": "string",
                  "format": "uuid",
                  "nullable": true
                },
                "subject": {
                  "type": "string",
                  "enum": [
                    "platform_policy",
                    "platform_kill",
                    "tenant_override",
                    "tenant_kill"
                  ]
                },
                "policy_version": {
                  "type": "integer",
                  "nullable": true
                },
                "layer": {
                  "type": "string",
                  "enum": ["platform", "bank"],
                  "nullable": true
                },
                "status": {
                  "type": "string",
                  "enum": ["draft", "approved", "active", "rejected"]
                },
                "actor_id": {
                  "type": "string",
                  "format": "uuid",
                  "nullable": true
                },
                "actor_role": {
                  "type": "string"
                },
                "approver_id": {
                  "type": "string",
                  "format": "uuid",
                  "nullable": true
                },
                "diff": {
                  "type": "object"
                },
                "reason": {
                  "type": "string",
                  "nullable": true
                },
                "created_at": {
                  "type": "string",
                  "format": "date-time"
                }
              }
            }
          }
        }
      },
      "AiTurnPolicy": {
        "type": "object",
        "description": "`ai.policy` of the turn context (ARCH-029a \u00a711.5): the workflows offer only these tools and actions, build the prompt's scope and blocked sections from it, and send `version` and `hash` back on traces and AI messages.",
        "required": [
          "version",
          "hash",
          "tools",
          "actions",
          "scope",
          "blocked",
          "locales",
          "caps",
          "kill"
        ],
        "properties": {
          "version": {
            "type": "integer"
          },
          "hash": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "tools": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AiPolicyTool"
            }
          },
          "actions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportActionKind"
            }
          },
          "scope": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AiPolicyScope"
            }
          },
          "blocked": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AiPolicyTopic"
            }
          },
          "handoff_always": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AiPolicyScope"
            }
          },
          "locales": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "refusal_reasons": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "caps": {
            "type": "object",
            "properties": {
              "monthly_token_cap": {
                "type": "integer",
                "format": "int64",
                "nullable": true
              },
              "turns_per_customer_hour": {
                "type": "integer"
              },
              "trace_retention_days": {
                "type": "integer"
              },
              "human_review_pct": {
                "type": "integer"
              }
            }
          },
          "profiles": {
            "type": "object",
            "properties": {
              "chat": {
                "$ref": "#/components/schemas/AiPolicyProfile"
              },
              "utility": {
                "$ref": "#/components/schemas/AiPolicyProfile"
              },
              "moderation": {
                "$ref": "#/components/schemas/AiPolicyProfile"
              }
            }
          },
          "zdr_required": {
            "type": "boolean"
          },
          "kill": {
            "type": "boolean"
          }
        }
      },
      "PlatformDocumentRetention": {
        "type": "object",
        "required": ["cdd_documents_years", "customer_letters_years"],
        "properties": {
          "cdd_documents_years": {
            "$ref": "#/components/schemas/PlatformDocumentRetentionDefault"
          },
          "customer_letters_years": {
            "$ref": "#/components/schemas/PlatformDocumentRetentionDefault"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "PlatformDocumentRetentionPatch": {
        "type": "object",
        "minProperties": 1,
        "properties": {
          "cdd_documents_years": {
            "type": "integer",
            "minimum": 5,
            "maximum": 30
          },
          "customer_letters_years": {
            "type": "integer",
            "minimum": 6,
            "maximum": 30
          }
        }
      },
      "TenantFeatureAdvice": {
        "type": "object",
        "description": "DEC-0031 advice; the licence pack advises, the bank decides.",
        "required": ["licence_pack", "features"],
        "properties": {
          "licence_pack": {
            "type": "string",
            "example": "emi"
          },
          "features": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["key", "enabled", "in_pack", "available"],
              "properties": {
                "key": {
                  "$ref": "#/components/schemas/TenantFeatureKey"
                },
                "enabled": {
                  "type": "boolean"
                },
                "in_pack": {
                  "type": "boolean",
                  "description": "Inside the typical scope of the licence pack (advice only)"
                },
                "available": {
                  "type": "boolean",
                  "description": "The platform can run it; false is refused for every tenant"
                },
                "note": {
                  "type": "string",
                  "enum": [
                    "no_mandate_flow",
                    "no_model_endpoint",
                    "evaluation_missing",
                    "templates_only",
                    "templates_unevaluated_locales",
                    "counsel_pending",
                    "no_file_store"
                  ],
                  "description": "Why the feature is not available (when `available` is false; `counsel_pending`, support_ai for the Art. 1b pack until counsel's opinion, DEC-0032; `no_file_store`, support_tickets without the support bucket, ARCH-030 \u00a73.1), or how an available feature runs (support_ai, ARCH-029a \u00a72.1 and \u00a72.3; `templates_only`, no model at all; `templates_unevaluated_locales`, the model only for `model_locales`). `no_model_endpoint` and `evaluation_missing` are no longer sent for support_ai."
                },
                "model_locales": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "example": "es"
                  },
                  "description": "support_ai with note `templates_unevaluated_locales` only. The languages the model may answer (SUPPORT_AI_EVALUATED_LOCALES); every other language runs templates."
                }
              }
            }
          }
        },
        "example": {
          "licence_pack": "emi",
          "features": [
            {
              "key": "sepa_sct",
              "enabled": true,
              "in_pack": true,
              "available": true
            },
            {
              "key": "sepa_instant",
              "enabled": true,
              "in_pack": true,
              "available": true
            },
            {
              "key": "sepa_dd",
              "enabled": false,
              "in_pack": false,
              "available": false,
              "note": "no_mandate_flow"
            },
            {
              "key": "swift",
              "enabled": false,
              "in_pack": true,
              "available": true
            },
            {
              "key": "sic",
              "enabled": false,
              "in_pack": false,
              "available": true
            },
            {
              "key": "sic_ip",
              "enabled": false,
              "in_pack": false,
              "available": true
            },
            {
              "key": "cards",
              "enabled": true,
              "in_pack": true,
              "available": true
            },
            {
              "key": "fx",
              "enabled": false,
              "in_pack": true,
              "available": true
            },
            {
              "key": "webhooks",
              "enabled": false,
              "in_pack": true,
              "available": true
            },
            {
              "key": "assistant",
              "enabled": false,
              "in_pack": true,
              "available": true
            },
            {
              "key": "support_chat",
              "enabled": true,
              "in_pack": true,
              "available": true
            },
            {
              "key": "support_ai",
              "enabled": false,
              "in_pack": true,
              "available": true,
              "note": "templates_only"
            },
            {
              "key": "support_tickets",
              "enabled": true,
              "in_pack": true,
              "available": true
            }
          ]
        }
      },
      "TenantFeatureAdvisory": {
        "type": "object",
        "required": ["feature", "code", "licence_pack"],
        "properties": {
          "feature": {
            "$ref": "#/components/schemas/TenantFeatureKey"
          },
          "code": {
            "type": "string",
            "enum": ["outside_licence_pack"]
          },
          "licence_pack": {
            "type": "string",
            "example": "emi"
          }
        }
      },
      "TenantFeaturesUpdated": {
        "type": "object",
        "description": "The tenant settings (as GET /tenants/{tenantId}/settings) plus `advisories`.",
        "required": ["features", "advisories"],
        "properties": {
          "sca_threshold": {
            "type": "integer",
            "deprecated": true,
            "description": "Always 0 since 0.34.0"
          },
          "sca_threshold_tenant": {
            "type": "integer",
            "deprecated": true,
            "description": "Always 0 since 0.34.0"
          },
          "sca_threshold_global": {
            "type": "integer",
            "deprecated": true,
            "description": "Always 0 since 0.34.0"
          },
          "single_transfer_limit": {
            "type": "integer"
          },
          "daily_transfer_limit": {
            "type": "integer"
          },
          "monthly_transfer_limit": {
            "type": "integer"
          },
          "max_customers": {
            "type": "integer"
          },
          "max_accounts_per_customer": {
            "type": "integer"
          },
          "features": {
            "type": "object",
            "additionalProperties": {
              "type": "boolean"
            }
          },
          "advisories": {
            "type": "array",
            "description": "Every enabled feature outside the licence pack, after the change.",
            "items": {
              "$ref": "#/components/schemas/TenantFeatureAdvisory"
            }
          }
        }
      },
      "TenantFeatureError": {
        "type": "object",
        "required": ["error"],
        "properties": {
          "error": {
            "type": "object",
            "required": ["code", "message"],
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "feature_unavailable",
                  "reason_required",
                  "human_route_required"
                ]
              },
              "message": {
                "type": "string"
              },
              "feature": {
                "type": "string",
                "description": "The feature refused (absent when a reason was sent that is not valid and none was needed)."
              },
              "note": {
                "type": "string",
                "enum": [
                  "no_mandate_flow",
                  "no_provider",
                  "no_model_endpoint",
                  "evaluation_missing",
                  "counsel_pending",
                  "no_file_store"
                ],
                "description": "feature_unavailable only. `counsel_pending`, support_ai for the Art. 1b licence pack (Newton) until counsel's opinion (DEC-0032). `no_file_store`, support_tickets without the support bucket (ARCH-030 \u00a73.1)."
              },
              "licence_pack": {
                "type": "string",
                "description": "reason_required only."
              }
            }
          }
        }
      },
      "HistoryError": {
        "type": "object",
        "required": ["error", "message"],
        "properties": {
          "error": {
            "type": "string",
            "enum": [
              "invalid_cursor",
              "invalid_limit",
              "invalid_filter",
              "invalid_id",
              "search_too_broad",
              "search_busy",
              "history_unavailable",
              "history_failed"
            ]
          },
          "message": {
            "type": "string"
          }
        }
      },
      "ProblemError": {
        "type": "object",
        "description": "Error body of the DEC-0030 routes.",
        "required": ["error"],
        "properties": {
          "error": {
            "type": "object",
            "required": ["code", "message"],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      },
      "TimelineStep": {
        "type": "object",
        "required": ["key", "state", "at"],
        "properties": {
          "key": {
            "type": "string",
            "description": "Closed vocabulary; a client renders an unknown key as a neutral\ngeneric step.\n",
            "enum": [
              "created",
              "checked",
              "approval",
              "sent",
              "in_network",
              "arrived",
              "received",
              "on_hold",
              "credited",
              "converted",
              "authorized",
              "settled",
              "reversed",
              "refunded",
              "returned",
              "failed",
              "cancelled"
            ]
          },
          "state": {
            "type": "string",
            "enum": ["done", "current", "upcoming", "failed", "skipped"],
            "description": "Exactly one step is `current` while the outcome is `in_progress`, none otherwise."
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the step was reached (RFC 3339 UTC); null unless done or failed."
          },
          "expected_at": {
            "type": "string",
            "format": "date-time",
            "description": "On an upcoming `arrived` or `credited` step, when known."
          },
          "detail": {
            "type": "object",
            "description": "`in_network` / `arrived`: `gpi`, `reason` (provider status and\nreason). `approval`: `result` (pending, approved, rejected,\nexpired). `returned`: `reason_code`, `reason` (plain English).\n`failed`: `reason_code`. Omitted when empty.\n",
            "properties": {
              "gpi": {
                "type": "string"
              },
              "reason": {
                "type": "string"
              },
              "result": {
                "type": "string",
                "enum": ["pending", "approved", "rejected", "expired"]
              },
              "reason_code": {
                "type": "string"
              }
            }
          }
        }
      },
      "TransferTimeline": {
        "type": "object",
        "required": [
          "transfer_id",
          "rail",
          "direction",
          "status",
          "outcome",
          "steps",
          "references"
        ],
        "properties": {
          "transfer_id": {
            "type": "string"
          },
          "rail": {
            "type": "string",
            "enum": [
              "internal",
              "sepa_sct",
              "sepa_inst",
              "sic",
              "sic_ip",
              "swift",
              "card",
              "fx",
              "fee",
              "other"
            ]
          },
          "direction": {
            "type": "string",
            "enum": ["out", "in", "internal"],
            "description": "The customer's view for a customer JWT; for staff, from the platform leg."
          },
          "status": {
            "type": "string",
            "enum": ["completed", "pending", "failed", "cancelled", "voided"],
            "description": "Ledger status."
          },
          "outcome": {
            "type": "string",
            "enum": [
              "in_progress",
              "completed",
              "failed",
              "returned",
              "cancelled"
            ]
          },
          "expected_by": {
            "type": "string",
            "format": "date-time",
            "description": "While in progress, when the payment should arrive (see the route)."
          },
          "steps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TimelineStep"
            }
          },
          "references": {
            "type": "object",
            "description": "Each key only when known.",
            "properties": {
              "reference": {
                "type": "string"
              },
              "end_to_end_id": {
                "type": "string"
              },
              "uetr": {
                "type": "string"
              }
            }
          }
        }
      },
      "Mt103Field": {
        "type": "object",
        "required": ["tag", "name", "value"],
        "properties": {
          "tag": {
            "type": "string",
            "example": "32A"
          },
          "name": {
            "type": "string",
            "example": "value_date_currency_amount"
          },
          "value": {
            "type": "string",
            "description": "Field content; lines of a multi-line field are separated by `\\n`."
          }
        }
      },
      "TransferSwift": {
        "type": "object",
        "required": ["message_type", "mt103"],
        "properties": {
          "uetr": {
            "type": "string",
            "description": "UUID v4"
          },
          "message_type": {
            "type": "string",
            "enum": ["pacs.008.001.08"]
          },
          "charge_bearer": {
            "type": "string",
            "enum": ["our", "sha", "ben"]
          },
          "intermediary_bic": {
            "type": "string"
          },
          "beneficiary_bic": {
            "type": "string"
          },
          "beneficiary_bank_name": {
            "type": "string"
          },
          "beneficiary_bank_country": {
            "type": "string"
          },
          "purpose_code": {
            "type": "string"
          },
          "remittance_info": {
            "type": "string"
          },
          "gpi": {
            "type": "object",
            "description": "Latest provider status, when one was reported.",
            "required": ["status"],
            "properties": {
              "status": {
                "type": "string",
                "example": "ACSP"
              },
              "reason": {
                "type": "string",
                "example": "G000"
              },
              "updated_at": {
                "type": "string",
                "format": "date-time"
              }
            }
          },
          "mt103": {
            "type": "array",
            "description": "20, 23B, 32A, 50K, 52A, 56A, 57A, 59, 70, 71A; a tag without data is left out.",
            "items": {
              "$ref": "#/components/schemas/Mt103Field"
            }
          }
        }
      },
      "TransferEventRequest": {
        "type": "object",
        "required": ["step"],
        "properties": {
          "step": {
            "type": "string",
            "enum": ["in_network", "arrived", "returned", "failed"]
          },
          "occurred_at": {
            "type": "string",
            "format": "date-time"
          },
          "code": {
            "type": "string",
            "maxLength": 16,
            "pattern": "^[A-Za-z0-9_]*$",
            "description": "Provider status or reason (ACSP, ACCC, RJCT, AC04)."
          },
          "reason": {
            "type": "string",
            "maxLength": 16,
            "pattern": "^[A-Za-z0-9_]*$",
            "description": "Reason next to the status (gpi G000, return reason AC04)."
          }
        }
      },
      "TransferEventResult": {
        "type": "object",
        "required": ["transfer_id", "step", "code", "recorded"],
        "properties": {
          "transfer_id": {
            "type": "string"
          },
          "step": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "recorded": {
            "type": "boolean",
            "description": "false when the same report was already recorded"
          }
        }
      },
      "HistoryPage": {
        "type": "object",
        "required": ["total", "next_cursor", "has_more"],
        "properties": {
          "total": {
            "type": "integer",
            "description": "Rows on this page (not a count of all rows)."
          },
          "next_cursor": {
            "type": "string",
            "nullable": true,
            "description": "Send as `cursor` for the next page; `null` on the last page."
          },
          "has_more": {
            "type": "boolean",
            "description": "Whether another page follows."
          }
        }
      },
      "ScreeningConfig": {
        "type": "object",
        "description": "Per-tenant sanctions screening configuration (BR-EF-026)",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid"
          },
          "provider": {
            "type": "string",
            "default": "sanctions_io"
          },
          "min_score": {
            "type": "number",
            "minimum": 0.5,
            "maximum": 1.0,
            "default": 0.85
          },
          "auto_clear_score": {
            "type": "number",
            "minimum": 0.5,
            "maximum": 1.0,
            "default": 0.7
          },
          "review_threshold": {
            "type": "number",
            "minimum": 0.5,
            "maximum": 1.0,
            "default": 0.85
          },
          "data_sources": {
            "type": "string",
            "default": "SANCTIONS-LISTS,PEP"
          },
          "adverse_media_enabled": {
            "type": "boolean",
            "default": false
          },
          "adverse_media_keywords": {
            "type": "string"
          },
          "monitoring_enabled": {
            "type": "boolean",
            "default": false
          },
          "transfer_rescreen_hours": {
            "type": "integer",
            "default": 24
          },
          "floor": {
            "$ref": "#/components/schemas/ScreeningFloor"
          }
        }
      },
      "ScreeningFloor": {
        "type": "object",
        "description": "The platform's ceilings on a bank's screening thresholds (migration\n279): the bank can only tighten. A lower score or fewer hours is\nstricter. `scope` is the jurisdiction of the row, `*` the platform\ndefault.\n",
        "properties": {
          "scope": {
            "type": "string"
          },
          "min_score_max": {
            "type": "number"
          },
          "auto_clear_max": {
            "type": "number"
          },
          "review_threshold_max": {
            "type": "number"
          },
          "rescreen_hours_max": {
            "type": "integer"
          },
          "required_sources": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "monitoring_required": {
            "type": "boolean"
          },
          "basis": {
            "type": "string"
          }
        }
      },
      "ScreeningConfigHistory": {
        "type": "object",
        "properties": {
          "history": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "changed_at": {
                  "type": "string",
                  "format": "date-time"
                },
                "actor_ref": {
                  "type": "string",
                  "description": "staff:<uuid>, service or migration:<n>"
                },
                "actor_id": {
                  "type": "string",
                  "format": "uuid",
                  "nullable": true
                },
                "actor_email": {
                  "type": "string",
                  "nullable": true
                },
                "actor_role": {
                  "type": "string",
                  "nullable": true
                },
                "reason": {
                  "type": "string"
                },
                "direction": {
                  "type": "string",
                  "enum": ["tighten", "loosen", "mixed"]
                },
                "before": {
                  "type": "object"
                },
                "after": {
                  "type": "object"
                },
                "floor": {
                  "type": "object"
                }
              }
            }
          }
        }
      },
      "ScreeningConfigUpdate": {
        "type": "object",
        "description": "Partial update for screening config; `reason` is required.",
        "required": ["reason"],
        "properties": {
          "reason": {
            "type": "string",
            "minLength": 10,
            "maxLength": 1000
          },
          "min_score": {
            "type": "number",
            "minimum": 0.5,
            "maximum": 1.0
          },
          "auto_clear_score": {
            "type": "number",
            "minimum": 0.5,
            "maximum": 1.0
          },
          "review_threshold": {
            "type": "number",
            "minimum": 0.5,
            "maximum": 1.0
          },
          "data_sources": {
            "type": "string",
            "description": "Comma-separated list (e.g. SANCTIONS-LISTS,PEP)"
          },
          "adverse_media_enabled": {
            "type": "boolean"
          },
          "adverse_media_keywords": {
            "type": "string"
          },
          "monitoring_enabled": {
            "type": "boolean"
          },
          "transfer_rescreen_hours": {
            "type": "integer",
            "minimum": 1
          }
        }
      },
      "ScreeningOutcome": {
        "type": "object",
        "description": "Result of a screening operation",
        "properties": {
          "result_id": {
            "type": "string",
            "format": "uuid"
          },
          "decision": {
            "type": "string",
            "enum": ["no_match", "auto_cleared", "potential_match"]
          },
          "match_count": {
            "type": "integer"
          },
          "highest_score": {
            "type": "number"
          },
          "status": {
            "type": "string"
          },
          "is_error": {
            "type": "boolean"
          },
          "error_message": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "BatchSubject": {
        "type": "object",
        "description": "Subject for batch screening",
        "required": ["name", "subject_id", "entity_type"],
        "properties": {
          "name": {
            "type": "string"
          },
          "subject_type": {
            "type": "string",
            "enum": ["customer", "beneficiary", "ubo"]
          },
          "subject_id": {
            "type": "string",
            "format": "uuid"
          },
          "entity_type": {
            "type": "string",
            "enum": ["person", "entity", "organisation"]
          },
          "date_of_birth": {
            "type": "string",
            "format": "date"
          },
          "nationality": {
            "type": "string",
            "maxLength": 2
          },
          "country": {
            "type": "string",
            "maxLength": 2
          }
        }
      },
      "CaseApproval": {
        "type": "object",
        "description": "A request for a second officer on a case decision (DEC-0035,\nmigration 246). `can` is computed for the caller.\n",
        "required": [
          "id",
          "case_id",
          "action",
          "status",
          "payload",
          "requested_by",
          "requested_at",
          "decided_by",
          "decided_at",
          "decision_reason",
          "approver_available",
          "can"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "case_id": {
            "type": "string",
            "format": "uuid"
          },
          "action": {
            "type": "string",
            "enum": [
              "lift_freeze",
              "close_false_positive",
              "close_no_sar",
              "escalate",
              "propose_sar",
              "close_incident"
            ],
            "description": "The step asked. escalate, propose_sar and close_incident only when the bank's workflow gates them (migration 281); close_no_sar and close_false_positive also on the case types a bank adds."
          },
          "status": {
            "type": "string",
            "enum": ["pending", "approved", "rejected", "withdrawn"]
          },
          "payload": {
            "type": "object",
            "description": "lift_freeze: `reason`; every other action: `rationale` and `band_decision`.",
            "properties": {
              "reason": {
                "type": "string"
              },
              "rationale": {
                "type": "string"
              },
              "band_decision": {
                "type": "string",
                "enum": ["agree", "override"]
              }
            }
          },
          "requested_by": {
            "$ref": "#/components/schemas/CaseApprovalPerson"
          },
          "requested_at": {
            "type": "string",
            "format": "date-time"
          },
          "decided_by": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/CaseApprovalPerson"
              },
              {
                "type": "null"
              }
            ]
          },
          "decided_at": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "decision_reason": {
            "type": ["string", "null"]
          },
          "approver_available": {
            "type": "boolean",
            "description": "Another active `mlro` of the bank's cell exists."
          },
          "can": {
            "type": "object",
            "required": ["approve", "reject", "withdraw"],
            "properties": {
              "approve": {
                "type": "boolean"
              },
              "reject": {
                "type": "boolean"
              },
              "withdraw": {
                "type": "boolean"
              }
            }
          }
        }
      },
      "CaseApprovalPerson": {
        "type": "object",
        "required": ["id", "email", "role"],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "email": {
            "type": "string"
          },
          "role": {
            "type": "string"
          }
        }
      },
      "CaseApprovalPending": {
        "type": "object",
        "description": "The request that waits on a case (list and detail rows).",
        "required": ["id", "action", "requested_by_email", "requested_at"],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "action": {
            "type": "string",
            "enum": [
              "lift_freeze",
              "close_false_positive",
              "close_no_sar",
              "escalate",
              "propose_sar",
              "close_incident"
            ]
          },
          "requested_by_email": {
            "type": "string"
          },
          "requested_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CaseApprovalAccepted": {
        "type": "object",
        "required": ["status", "approval"],
        "properties": {
          "status": {
            "type": "string",
            "enum": ["pending_approval"]
          },
          "approval": {
            "$ref": "#/components/schemas/CaseApproval"
          }
        }
      },
      "DecisionPayment": {
        "type": "object",
        "description": "One payment as the decision view shows it. The counterparty's IBAN\nis cut to its country and last four characters.\n",
        "properties": {
          "transfer_id": {
            "type": "string"
          },
          "direction": {
            "type": "string",
            "enum": ["in", "out", "internal", "other"]
          },
          "amount": {
            "type": "integer",
            "format": "int64",
            "description": "Minor units"
          },
          "currency": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "value_date": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "status": {
            "type": "string",
            "nullable": true
          },
          "settlement_status": {
            "type": "string",
            "nullable": true
          },
          "held_until": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "released_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "returned_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "rail": {
            "type": "string",
            "nullable": true
          },
          "transfer_type": {
            "type": "string",
            "nullable": true
          },
          "reference": {
            "type": "string",
            "nullable": true
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "from_name": {
            "type": "string",
            "nullable": true
          },
          "to_name": {
            "type": "string",
            "nullable": true
          },
          "counterparty": {
            "type": "string",
            "nullable": true
          },
          "counterparty_country": {
            "type": "string",
            "nullable": true
          },
          "counterparty_iban_country": {
            "type": "string",
            "nullable": true
          },
          "counterparty_iban_last4": {
            "type": "string",
            "nullable": true
          },
          "counterparty_bic": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "DecisionContext": {
        "type": "object",
        "description": "GET /api/v1/compliance-cases/decision-context.",
        "required": [
          "customer",
          "accounts",
          "ubos",
          "payment",
          "related",
          "rule",
          "hits",
          "kyc",
          "cdd",
          "activity",
          "history",
          "open_case",
          "people"
        ],
        "properties": {
          "customer": {
            "type": "object",
            "nullable": true,
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "type": {
                "type": "string",
                "enum": ["individual", "business"]
              },
              "name": {
                "type": "string",
                "nullable": true
              },
              "country": {
                "type": "string",
                "nullable": true
              },
              "nationality": {
                "type": "string",
                "nullable": true
              },
              "date_of_birth": {
                "type": "string",
                "format": "date",
                "nullable": true
              },
              "incorporation_date": {
                "type": "string",
                "format": "date",
                "nullable": true
              },
              "legal_form": {
                "type": "string",
                "nullable": true
              },
              "registration_number": {
                "type": "string",
                "nullable": true
              },
              "industry_code": {
                "type": "string",
                "nullable": true
              },
              "customer_since": {
                "type": "string",
                "format": "date-time"
              },
              "status": {
                "type": "string"
              },
              "kyc_status": {
                "type": "string",
                "nullable": true
              },
              "kyc_verified_at": {
                "type": "string",
                "format": "date-time",
                "nullable": true
              },
              "kyc_reviewed_at": {
                "type": "string",
                "format": "date-time",
                "nullable": true
              },
              "kyc_expires_at": {
                "type": "string",
                "format": "date-time",
                "nullable": true
              },
              "last_full_cdd_at": {
                "type": "string",
                "format": "date-time",
                "nullable": true
              },
              "risk_level": {
                "type": "string",
                "nullable": true
              },
              "risk_score": {
                "type": "integer",
                "nullable": true
              },
              "risk_factors": {
                "type": "array",
                "nullable": true,
                "items": {
                  "type": "string"
                }
              },
              "screening_status": {
                "type": "string",
                "nullable": true
              },
              "last_screening": {
                "type": "object",
                "nullable": true,
                "properties": {
                  "status": {
                    "type": "string"
                  },
                  "at": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "score": {
                    "type": "string",
                    "nullable": true
                  },
                  "match_kind": {
                    "type": "string",
                    "nullable": true
                  }
                }
              },
              "open_matches": {
                "type": "integer"
              },
              "declared_monthly_amount": {
                "type": "integer",
                "format": "int64",
                "nullable": true,
                "description": "Minor units"
              },
              "expected_countries": {
                "type": "array",
                "nullable": true,
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "accounts": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "wallet_id": {
                  "type": "string",
                  "format": "uuid"
                },
                "currency": {
                  "type": "string",
                  "nullable": true
                },
                "status": {
                  "type": "string"
                },
                "primary": {
                  "type": "boolean"
                },
                "frozen": {
                  "type": "boolean"
                },
                "frozen_by": {
                  "type": "string",
                  "nullable": true
                },
                "since": {
                  "type": "string",
                  "format": "date-time"
                },
                "iban_country": {
                  "type": "string",
                  "nullable": true
                },
                "iban_last4": {
                  "type": "string",
                  "nullable": true
                }
              }
            }
          },
          "ubos": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "ownership_pct": {
                  "type": "string"
                },
                "controlling": {
                  "type": "boolean"
                }
              }
            }
          },
          "payment": {
            "nullable": true,
            "allOf": [
              {
                "$ref": "#/components/schemas/DecisionPayment"
              }
            ]
          },
          "related": {
            "type": "object",
            "properties": {
              "basis": {
                "type": "string",
                "enum": ["inbound_before", "outbound_window", "none"]
              },
              "window_hours": {
                "type": "integer"
              },
              "payments": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/DecisionPayment"
                }
              }
            }
          },
          "rule": {
            "type": "object",
            "nullable": true,
            "description": "The rule in force for the typology, and the facts recorded with the hit and on the alert.",
            "additionalProperties": true
          },
          "hits": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "nullable": true
                },
                "list": {
                  "type": "string",
                  "nullable": true
                },
                "score": {
                  "type": "string",
                  "nullable": true
                },
                "program": {
                  "type": "string",
                  "nullable": true
                },
                "date_of_birth": {
                  "type": "string",
                  "nullable": true
                },
                "country": {
                  "type": "string",
                  "nullable": true
                },
                "entity_type": {
                  "type": "string",
                  "nullable": true
                }
              }
            }
          },
          "kyc": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "cdd": {
            "type": "object",
            "nullable": true,
            "additionalProperties": true
          },
          "activity": {
            "type": "object",
            "properties": {
              "totals": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": true
                }
              },
              "weeks": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": true
                }
              },
              "top_counterparties": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": true
                }
              },
              "top_countries": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": true
                }
              },
              "new_payees_30d": {
                "type": "integer"
              },
              "largest_out": {
                "nullable": true,
                "allOf": [
                  {
                    "$ref": "#/components/schemas/DecisionPayment"
                  }
                ]
              }
            }
          },
          "history": {
            "type": "object",
            "properties": {
              "cases": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": true
                }
              },
              "alerts": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": true
                }
              },
              "freezes": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": true
                }
              },
              "sars": {
                "type": "array",
                "nullable": true,
                "description": "Null for a role that does not read reports.",
                "items": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "open_case": {
            "type": "object",
            "nullable": true,
            "description": "The open case on the same source; an alert worked in a case is decided there.",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "status": {
                "type": "string"
              },
              "case_type": {
                "type": "string"
              },
              "created_at": {
                "type": "string",
                "format": "date-time"
              }
            }
          },
          "people": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "email": {
                  "type": "string"
                },
                "name": {
                  "type": "string",
                  "nullable": true
                },
                "role": {
                  "type": "string",
                  "description": "The cell role; super_admin for the platform."
                }
              }
            }
          }
        }
      },
      "CaseWorkflow": {
        "type": "object",
        "required": ["transitions"],
        "properties": {
          "transitions": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "key",
                "from",
                "to",
                "four_eyes",
                "four_eyes_case_types",
                "never_gated",
                "reason_min"
              ],
              "properties": {
                "key": {
                  "type": "string",
                  "enum": [
                    "start",
                    "freeze",
                    "lift_freeze",
                    "escalate",
                    "propose_sar",
                    "file_sar",
                    "withdraw_sar",
                    "close_no_sar",
                    "close_false_positive",
                    "close_incident"
                  ]
                },
                "from": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "enum": [
                      "open",
                      "investigating",
                      "pending_filing",
                      "closed"
                    ]
                  }
                },
                "to": {
                  "type": ["string", "null"],
                  "enum": [
                    "open",
                    "investigating",
                    "pending_filing",
                    "closed",
                    null
                  ]
                },
                "open_to": {
                  "type": ["string", "null"],
                  "enum": ["investigating", null]
                },
                "four_eyes": {
                  "type": "boolean"
                },
                "four_eyes_case_types": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "never_gated": {
                  "type": "boolean"
                },
                "case_types": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "disposition": {
                  "type": ["string", "null"],
                  "enum": [
                    "sar",
                    "no_sar",
                    "freeze",
                    "escalate",
                    "false_positive",
                    null
                  ]
                },
                "reason_min": {
                  "type": "integer",
                  "minimum": 0,
                  "description": "The effective minimum on every case type (a bank may ask more per type, `bank_reason_min`)."
                },
                "platform_four_eyes": {
                  "type": "boolean"
                },
                "platform_four_eyes_case_types": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "platform_reason_min": {
                  "type": "integer",
                  "minimum": 0
                },
                "bank_four_eyes_case_types": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  },
                  "description": "Case types (`*`: all) on which the bank added a second officer."
                },
                "bank_reason_min": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": ["case_type", "reason_min"],
                    "properties": {
                      "case_type": {
                        "type": "string"
                      },
                      "reason_min": {
                        "type": "integer",
                        "minimum": 10,
                        "maximum": 2000
                      }
                    }
                  }
                },
                "four_eyes_configurable": {
                  "type": "boolean"
                },
                "reason_configurable": {
                  "type": "boolean"
                }
              }
            }
          },
          "reason_min": {
            "type": "integer",
            "minimum": 0
          },
          "approval_reason_max": {
            "type": "integer",
            "minimum": 1
          },
          "bank_reason_max": {
            "type": "integer",
            "minimum": 1
          },
          "case_types": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "case_review_days": {
            "type": "object",
            "required": ["platform", "bank", "effective"],
            "properties": {
              "platform": {
                "type": "integer",
                "minimum": 1
              },
              "bank": {
                "type": ["integer", "null"],
                "minimum": 1
              },
              "effective": {
                "type": "integer",
                "minimum": 1
              }
            }
          },
          "bank_version": {
            "type": ["object", "null"],
            "description": "The active overlay (null without one).",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "version": {
                "type": "integer"
              },
              "activated_at": {
                "type": "string",
                "format": "date-time"
              },
              "requested_by_email": {
                "type": "string"
              },
              "decided_by_email": {
                "type": "string"
              }
            }
          }
        }
      },
      "CaseWorkflowRule": {
        "type": "object",
        "description": "A bank's tightening of one step on one case type (`*`, every type).",
        "required": ["step", "case_type"],
        "properties": {
          "step": {
            "type": "string",
            "enum": [
              "start",
              "freeze",
              "lift_freeze",
              "escalate",
              "propose_sar",
              "file_sar",
              "withdraw_sar",
              "close_no_sar",
              "close_false_positive",
              "close_incident"
            ]
          },
          "case_type": {
            "type": "string"
          },
          "four_eyes": {
            "type": "boolean",
            "description": "true: a second officer approves the step"
          },
          "reason_min": {
            "type": ["integer", "null"],
            "minimum": 10,
            "maximum": 2000
          }
        }
      },
      "CaseWorkflowVersion": {
        "type": "object",
        "required": [
          "id",
          "version",
          "status",
          "rules",
          "reason",
          "requested_by",
          "requested_at",
          "can"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "version": {
            "type": "integer",
            "minimum": 1
          },
          "status": {
            "type": "string",
            "enum": ["pending", "active", "superseded", "rejected", "withdrawn"]
          },
          "rules": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CaseWorkflowRule"
            }
          },
          "case_review_days": {
            "type": ["integer", "null"]
          },
          "reason": {
            "type": "string"
          },
          "base_version": {
            "type": ["integer", "null"]
          },
          "requested_by": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "email": {
                "type": "string"
              }
            }
          },
          "requested_at": {
            "type": "string",
            "format": "date-time"
          },
          "decided_by": {
            "type": ["object", "null"],
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "email": {
                "type": "string"
              }
            }
          },
          "decided_at": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "decision_reason": {
            "type": ["string", "null"]
          },
          "activated_at": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "superseded_at": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "can": {
            "type": "object",
            "required": ["approve", "reject", "withdraw"],
            "properties": {
              "approve": {
                "type": "boolean"
              },
              "reject": {
                "type": "boolean"
              },
              "withdraw": {
                "type": "boolean"
              }
            }
          }
        }
      },
      "CaseWorkflowEvent": {
        "type": "object",
        "required": [
          "id",
          "version_id",
          "version",
          "event",
          "actor",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "version_id": {
            "type": "string",
            "format": "uuid"
          },
          "version": {
            "type": "integer"
          },
          "event": {
            "type": "string",
            "enum": [
              "requested",
              "activated",
              "rejected",
              "withdrawn",
              "superseded"
            ]
          },
          "actor": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "email": {
                "type": "string"
              }
            }
          },
          "reason": {
            "type": ["string", "null"]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CaseWorkflowBankState": {
        "type": "object",
        "required": [
          "active",
          "pending",
          "versions",
          "history",
          "case_review_days"
        ],
        "properties": {
          "active": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/CaseWorkflowVersion"
              },
              {
                "type": "null"
              }
            ]
          },
          "pending": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/CaseWorkflowVersion"
              },
              {
                "type": "null"
              }
            ]
          },
          "versions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CaseWorkflowVersion"
            }
          },
          "history": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CaseWorkflowEvent"
            }
          },
          "case_review_days": {
            "type": "object",
            "properties": {
              "platform": {
                "type": "integer"
              },
              "effective": {
                "type": "integer"
              }
            }
          }
        }
      },
      "CaseWorkflowViolations": {
        "type": "object",
        "required": ["error", "violations"],
        "properties": {
          "error": {
            "type": "string",
            "enum": ["tighten_only_violation"]
          },
          "violations": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["index", "field", "reason"],
              "properties": {
                "index": {
                  "type": ["integer", "null"],
                  "description": "The rule's index; null for case_review_days or rules"
                },
                "field": {
                  "type": "string"
                },
                "reason": {
                  "type": "string",
                  "enum": [
                    "four_eyes_required_by_platform",
                    "freeze_never_gated",
                    "four_eyes_not_configurable",
                    "below_platform_minimum",
                    "above_maximum",
                    "step_has_no_reason",
                    "step_not_for_case_type",
                    "tightens_nothing",
                    "duplicate_rule",
                    "unknown_step",
                    "unknown_case_type",
                    "not_a_whole_number",
                    "not_a_boolean",
                    "not_an_object",
                    "not_an_array",
                    "too_many_rules",
                    "above_jurisdiction",
                    "below_one_day"
                  ]
                }
              }
            }
          }
        }
      },
      "ScreeningCaseOpened": {
        "type": "object",
        "required": ["case_id", "created"],
        "properties": {
          "case_id": {
            "type": "string",
            "format": "uuid"
          },
          "created": {
            "type": "boolean"
          }
        }
      },
      "ScreeningResult": {
        "type": "object",
        "description": "Immutable screening result record (BR-EF-026)",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid"
          },
          "subject_type": {
            "type": "string",
            "enum": ["customer", "beneficiary", "ubo"]
          },
          "subject_id": {
            "type": "string",
            "format": "uuid"
          },
          "subject_name": {
            "type": "string"
          },
          "trigger_type": {
            "type": "string",
            "enum": [
              "onboarding",
              "transfer",
              "cdd_rescreen",
              "monitoring",
              "manual",
              "adverse_media"
            ]
          },
          "trigger_reference": {
            "type": "string",
            "nullable": true
          },
          "provider": {
            "type": "string",
            "default": "sanctions_io"
          },
          "provider_search_id": {
            "type": "string",
            "nullable": true
          },
          "provider_timestamp": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "api_version": {
            "type": "string",
            "nullable": true
          },
          "match_count": {
            "type": "integer"
          },
          "highest_score": {
            "type": "number"
          },
          "matches": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Raw match data from the screening provider"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "no_match",
              "auto_cleared",
              "potential_match",
              "confirmed_match",
              "false_positive"
            ]
          },
          "resolved_by": {
            "type": "string",
            "nullable": true
          },
          "resolved_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "resolution_notes": {
            "type": "string",
            "nullable": true
          },
          "request_params": {
            "type": "object",
            "description": "Original search parameters"
          },
          "match_kind": {
            "type": "string",
            "enum": ["unknown", "pep", "sanctions", "mixed"],
            "description": "PEP vs sanctions typology. Confirming PEP MUST NOT block."
          },
          "seco_followup": {
            "type": "string",
            "enum": ["not_applicable", "open", "done"],
            "description": "CH sanctions SECO path. Completing it does not close MROS."
          },
          "mros_followup": {
            "type": "string",
            "enum": ["not_applicable", "open", "done"],
            "description": "CH sanctions MROS path. Completing it does not close SECO."
          },
          "match_kind_effective": {
            "type": "string",
            "enum": ["unknown", "pep", "sanctions", "mixed"],
            "description": "The kind a decision acts on: match_kind, else what the match payload reads as. Core decides Resolve or Open case on it."
          },
          "case_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "Detail only. The open compliance case that decides this result\n(its stored `screening_result_id`, migration 233), else the latest\nclosed case that pointed at it. A sanctions match is decided on\nthat case (ES-case-decides-screening). A failed lookup gives null.\n"
          },
          "case_open": {
            "type": "boolean",
            "description": "Detail only. Whether case_id is still open. A closed case without a decision leaves the result to a new case."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ScreeningResultList": {
        "type": "object",
        "description": "Wrapper for a list of prior screening results",
        "properties": {
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ScreeningResult"
            }
          },
          "total": {
            "type": "integer"
          }
        }
      },
      "ScreeningAlert": {
        "type": "object",
        "description": "Monitoring alert from continuous screening (BR-EF-026)",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid"
          },
          "monitor_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "provider_alert_id": {
            "type": "string",
            "nullable": true
          },
          "alert_type": {
            "type": "string",
            "enum": [
              "new_match",
              "updated_match",
              "removed_match",
              "adverse_media",
              "onboarding_match",
              "tm_shadow"
            ]
          },
          "match_data": {
            "type": "object",
            "description": "Alert payload from the screening provider"
          },
          "status": {
            "type": "string",
            "enum": ["open", "acknowledged", "escalated", "resolved"]
          },
          "resolved_by": {
            "type": "string",
            "nullable": true
          },
          "resolved_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "resolution": {
            "type": "string",
            "nullable": true
          },
          "notes": {
            "type": "string",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "customer_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "List hits: the customer the hit is on (joined)"
          },
          "customer_name": {
            "type": "string",
            "nullable": true,
            "description": "List hits: the customer's display name"
          },
          "list_name": {
            "type": "string",
            "nullable": true,
            "description": "List hits: the list matched (e.g. PEP, OFAC SDN)"
          },
          "matched_name": {
            "type": "string",
            "nullable": true,
            "description": "List hits: the list entry matched"
          },
          "match_score": {
            "type": "number",
            "nullable": true,
            "description": "List hits: match score from 0 to 1"
          },
          "list_kind": {
            "type": "string",
            "nullable": true,
            "enum": [
              "pep",
              "sanctions",
              "mixed",
              "adverse_media",
              "unknown",
              null
            ],
            "description": "List hits: which kind of list; null for tm_shadow"
          }
        }
      },
      "ScreeningStats": {
        "type": "object",
        "description": "Screening statistics for MLRO dashboard (BR-EF-026)",
        "properties": {
          "total_screenings": {
            "type": "integer"
          },
          "pending_review": {
            "type": "integer"
          },
          "confirmed_matches": {
            "type": "integer"
          },
          "false_positives": {
            "type": "integer"
          },
          "auto_cleared": {
            "type": "integer"
          },
          "open_alerts": {
            "type": "integer"
          },
          "last_screening_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "ComplianceRule": {
        "type": "object",
        "description": "Officer-visible catalogue row (BR-EF-033). Not the TM evaluator.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "family": {
            "type": "string",
            "enum": [
              "onboarding",
              "payment",
              "monitoring",
              "cdd",
              "cash",
              "fraud"
            ]
          },
          "typology": {
            "type": "string"
          },
          "product": {
            "type": "string"
          },
          "window_hours": {
            "type": "integer"
          },
          "threshold_count": {
            "type": "integer"
          },
          "threshold_amount": {
            "type": "integer",
            "nullable": true
          },
          "currency": {
            "type": "string",
            "nullable": true
          },
          "action": {
            "type": "string",
            "enum": ["log", "alert"]
          },
          "evaluation_mode": {
            "type": "string",
            "enum": ["live", "shadow", "inventory"]
          },
          "evaluator": {
            "type": "string",
            "enum": ["none", "kyc", "screening", "native_tm", "cdd", "cash"]
          },
          "status": {
            "type": "string",
            "enum": ["draft", "active", "disabled"]
          },
          "version": {
            "type": "integer"
          },
          "regime": {
            "type": "string",
            "enum": ["both", "es_emi", "ch_art_1b"]
          },
          "hint": {
            "type": "string",
            "description": "What the rule does. No freeze claim unless freeze exists."
          },
          "rationale": {
            "type": "string",
            "description": "Why banks keep this row. Name the source."
          },
          "title": {
            "type": "string",
            "description": "Human name. Officers do not type a typology slug."
          },
          "condition_object": {
            "type": "string",
            "enum": ["none", "transfer", "customer", "screening", "cdd", "cash"]
          },
          "condition_compare": {
            "type": "string",
            "enum": ["first", "gte_count", "gte_amount", "status"]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "pending_change_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "A change of this rule waiting for a second MLRO."
          }
        }
      },
      "ComplianceRuleList": {
        "type": "object",
        "properties": {
          "rules": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ComplianceRule"
            }
          },
          "total": {
            "type": "integer"
          }
        }
      },
      "ComplianceRuleCreate": {
        "type": "object",
        "required": [
          "title",
          "condition_object",
          "condition_compare",
          "reason"
        ],
        "properties": {
          "reason": {
            "type": "string",
            "minLength": 10,
            "maxLength": 1000
          },
          "title": {
            "type": "string",
            "minLength": 3,
            "maxLength": 80
          },
          "condition_object": {
            "type": "string",
            "enum": ["transfer", "customer", "screening", "cdd", "cash"]
          },
          "condition_compare": {
            "type": "string",
            "enum": ["first", "gte_count", "gte_amount", "status"]
          },
          "hint": {
            "type": "string",
            "maxLength": 1000
          },
          "rationale": {
            "type": "string",
            "maxLength": 1500
          },
          "window_hours": {
            "type": "integer",
            "minimum": 0
          },
          "threshold_count": {
            "type": "integer",
            "minimum": 1
          },
          "threshold_amount": {
            "type": "integer",
            "nullable": true
          },
          "action": {
            "type": "string",
            "enum": ["log", "alert"]
          }
        }
      },
      "ComplianceRulePatch": {
        "type": "object",
        "required": ["reason"],
        "properties": {
          "reason": {
            "type": "string",
            "minLength": 10,
            "maxLength": 1000
          },
          "status": {
            "type": "string",
            "enum": ["active", "disabled"]
          },
          "threshold_count": {
            "type": "integer",
            "minimum": 1
          },
          "window_hours": {
            "type": "integer",
            "minimum": 0
          },
          "evaluation_mode": {
            "type": "string",
            "enum": ["live", "shadow", "inventory"]
          },
          "hint": {
            "type": "string",
            "maxLength": 1000
          },
          "rationale": {
            "type": "string",
            "maxLength": 1500
          },
          "action": {
            "type": "string",
            "enum": ["log", "alert"]
          },
          "evaluator": {
            "type": "string",
            "enum": ["none", "kyc", "screening", "native_tm", "cdd", "cash"]
          },
          "title": {
            "type": "string",
            "minLength": 3,
            "maxLength": 80
          },
          "condition_object": {
            "type": "string",
            "enum": ["transfer", "customer", "screening", "cdd", "cash"]
          },
          "condition_compare": {
            "type": "string",
            "enum": ["first", "gte_count", "gte_amount", "status"]
          },
          "threshold_amount": {
            "type": "integer",
            "nullable": true
          }
        }
      },
      "RuleRevisionList": {
        "type": "object",
        "properties": {
          "revisions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "version": {
                  "type": "integer"
                },
                "actor": {
                  "type": "string",
                  "description": "The requester's email",
                  "or seed.": null
                },
                "action": {
                  "type": "string",
                  "enum": ["created", "updated", "retired"]
                },
                "snapshot": {
                  "type": "object"
                },
                "created_at": {
                  "type": "string"
                },
                "reason": {
                  "type": "string",
                  "nullable": true
                },
                "change_id": {
                  "type": "string",
                  "format": "uuid",
                  "nullable": true
                },
                "requested_by": {
                  "type": "string",
                  "format": "uuid",
                  "nullable": true
                },
                "approved_by": {
                  "type": "string",
                  "format": "uuid",
                  "nullable": true
                },
                "approved_by_email": {
                  "type": "string",
                  "nullable": true
                }
              }
            }
          },
          "total": {
            "type": "integer"
          }
        }
      },
      "RuleChangePerson": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "email": {
            "type": "string"
          },
          "role": {
            "type": "string"
          }
        }
      },
      "RuleChange": {
        "type": "object",
        "description": "A change of the rule book (maker-checker, migration 278).",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "kind": {
            "type": "string",
            "enum": ["create", "update", "retire"]
          },
          "status": {
            "type": "string",
            "enum": ["pending", "approved", "rejected", "withdrawn"]
          },
          "rule_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "rule_title": {
            "type": "string",
            "nullable": true
          },
          "rule_typology": {
            "type": "string",
            "nullable": true
          },
          "rule_family": {
            "type": "string",
            "nullable": true
          },
          "rule_version": {
            "type": "integer",
            "nullable": true
          },
          "base_version": {
            "type": "integer",
            "nullable": true
          },
          "stale": {
            "type": "boolean"
          },
          "payload": {
            "type": "object",
            "description": "The proposed fields, as strings.",
            "additionalProperties": {
              "type": "string"
            }
          },
          "reason": {
            "type": "string"
          },
          "current": {
            "type": "object",
            "nullable": true,
            "description": "The rule as it stands."
          },
          "requested_by": {
            "$ref": "#/components/schemas/RuleChangePerson"
          },
          "requested_at": {
            "type": "string",
            "format": "date-time"
          },
          "decided_by": {
            "allOf": [
              {
                "$ref": "#/components/schemas/RuleChangePerson"
              }
            ],
            "nullable": true
          },
          "decided_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "decision_reason": {
            "type": "string",
            "nullable": true
          },
          "applied_rule_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "applied_version": {
            "type": "integer",
            "nullable": true
          },
          "approver_available": {
            "type": "boolean"
          },
          "can": {
            "type": "object",
            "properties": {
              "approve": {
                "type": "boolean"
              },
              "reject": {
                "type": "boolean"
              },
              "withdraw": {
                "type": "boolean"
              }
            }
          }
        }
      },
      "RuleChangeAnswer": {
        "type": "object",
        "properties": {
          "change": {
            "$ref": "#/components/schemas/RuleChange"
          }
        }
      },
      "RuleChangeList": {
        "type": "object",
        "properties": {
          "changes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RuleChange"
            }
          },
          "total": {
            "type": "integer"
          }
        }
      },
      "RuleBacktestRun": {
        "type": "object",
        "properties": {
          "window_hours": {
            "type": "integer"
          },
          "threshold_count": {
            "type": "integer"
          },
          "threshold_amount": {
            "type": "integer"
          },
          "scanned": {
            "type": "integer"
          },
          "hits": {
            "type": "integer"
          },
          "accounts": {
            "type": "integer"
          },
          "truncated": {
            "type": "boolean"
          },
          "sample": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "transfer_id": {
                  "type": "string"
                },
                "amount": {
                  "type": "integer"
                },
                "observed": {
                  "type": "integer"
                },
                "created_at": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "RuleBacktest": {
        "type": "object",
        "properties": {
          "supported": {
            "type": "boolean"
          },
          "days": {
            "type": "integer"
          },
          "predicate": {
            "type": "string",
            "enum": ["first", "count", "amount", "near", "round"]
          },
          "typology": {
            "type": "string"
          },
          "reason": {
            "type": "string",
            "enum": ["not_replayable"]
          },
          "proposed": {
            "$ref": "#/components/schemas/RuleBacktestRun"
          },
          "current": {
            "allOf": [
              {
                "$ref": "#/components/schemas/RuleBacktestRun"
              }
            ],
            "nullable": true
          }
        }
      },
      "Beneficiary": {
        "type": "object",
        "description": "Saved payment beneficiary (BR-EF-023)",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid"
          },
          "customer_id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": ["individual", "business"],
            "nullable": true,
            "description": "As sent on create or edit. null when the payee was saved without\na type (not known); finance-api does not assume `individual`.\n"
          },
          "iban": {
            "type": "string",
            "description": "IBAN (required if no account_number)",
            "example": "DE89370400440532013000"
          },
          "bic": {
            "type": "string"
          },
          "account_number": {
            "type": "string"
          },
          "routing_number": {
            "type": "string"
          },
          "bank_name": {
            "type": "string"
          },
          "bank_country": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "notes": {
            "type": "string"
          },
          "address_line1": {
            "type": "string"
          },
          "address_line2": {
            "type": "string"
          },
          "city": {
            "type": "string"
          },
          "postal_code": {
            "type": "string"
          },
          "country": {
            "type": "string"
          },
          "verification_status": {
            "type": "string",
            "enum": ["pending", "verified", "failed", "blocked"]
          },
          "screening_status": {
            "type": "string",
            "enum": [
              "pending",
              "clear",
              "potential_match",
              "confirmed_match",
              "false_positive"
            ],
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreateBeneficiaryRequest": {
        "type": "object",
        "required": ["name"],
        "description": "Either `iban` or both `account_number` and `routing_number` must be\nprovided. Customer JWT: `customer_id` and `tenant_id` are taken from\nthe JWT and may be omitted; a different value returns 403 `forbidden`.\nAdmin session or `X-Service-Key`: `customer_id` is required.\n",
        "properties": {
          "customer_id": {
            "type": "string",
            "format": "uuid"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": ["individual", "business"],
            "description": "Optional. Without it the payee is stored with type null (not known), not `individual`."
          },
          "iban": {
            "type": "string",
            "description": "ISO 13616. Spaces are removed and letters upper-cased; mod-97 must pass."
          },
          "bic": {
            "type": "string"
          },
          "account_number": {
            "type": "string"
          },
          "routing_number": {
            "type": "string"
          },
          "bank_name": {
            "type": "string"
          },
          "bank_country": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "notes": {
            "type": "string"
          },
          "address_line1": {
            "type": "string"
          },
          "address_line2": {
            "type": "string"
          },
          "city": {
            "type": "string"
          },
          "postal_code": {
            "type": "string"
          },
          "country": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "contact_id": {
            "type": "string",
            "format": "uuid",
            "description": "Root payee of the same customer (multi-currency contact). Other values return 400 `invalid_contact_id`, as does a payee deleted while the link waited for it (the link takes the payee's lock)."
          },
          "currencies": {
            "type": "string"
          }
        }
      },
      "PayeeAccount": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "currency": {
            "type": "string"
          },
          "scheme": {
            "type": "string",
            "enum": ["iban", "uk_account", "us_account", "swift"],
            "description": "Stored scheme, or derived (IBAN -> iban, bank_country GB -> uk_account, US -> us_account, else swift)."
          },
          "iban": {
            "type": "string",
            "nullable": true
          },
          "account_number": {
            "type": "string",
            "nullable": true
          },
          "routing_number": {
            "type": "string",
            "nullable": true
          },
          "bic": {
            "type": "string",
            "nullable": true
          },
          "bank_name": {
            "type": "string",
            "nullable": true
          },
          "bank_country": {
            "type": "string",
            "nullable": true
          },
          "is_default": {
            "type": "boolean",
            "description": "One per payee and currency; the oldest account of a currency when none was chosen."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Payee": {
        "type": "object",
        "description": "Payee contact (root row party fields) with nested accounts (BR-FM-008).",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "type": {
            "type": "string",
            "enum": ["individual", "business"],
            "nullable": true,
            "description": "null when the payee was saved without a type (not known)."
          },
          "name": {
            "type": "string"
          },
          "country": {
            "type": "string",
            "nullable": true
          },
          "address_line1": {
            "type": "string",
            "nullable": true
          },
          "address_line2": {
            "type": "string",
            "nullable": true
          },
          "city": {
            "type": "string",
            "nullable": true
          },
          "postal_code": {
            "type": "string",
            "nullable": true
          },
          "email": {
            "type": "string",
            "nullable": true
          },
          "notes": {
            "type": "string",
            "nullable": true
          },
          "verification_status": {
            "type": "string",
            "enum": ["pending", "verified", "failed", "sanctions_flagged"]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "accounts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PayeeAccount"
            }
          }
        }
      },
      "PayeeAccountRequest": {
        "type": "object",
        "description": "With `scheme`, its fields are required (else 400 `account_required`):\niban -> iban; uk_account and us_account -> account_number and\nrouting_number; swift -> account_number (or iban) and bic. Without\n`scheme`: iban, or account_number plus routing_number.\n",
        "properties": {
          "currency": {
            "type": "string"
          },
          "scheme": {
            "type": "string",
            "enum": ["iban", "uk_account", "us_account", "swift"]
          },
          "iban": {
            "type": "string"
          },
          "account_number": {
            "type": "string"
          },
          "routing_number": {
            "type": "string"
          },
          "bic": {
            "type": "string"
          },
          "bank_name": {
            "type": "string"
          },
          "bank_country": {
            "type": "string"
          }
        }
      },
      "PayeePartyRequest": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": ["individual", "business"]
          },
          "name": {
            "type": "string"
          },
          "country": {
            "type": "string"
          },
          "address_line1": {
            "type": "string"
          },
          "address_line2": {
            "type": "string"
          },
          "city": {
            "type": "string"
          },
          "postal_code": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "notes": {
            "type": "string"
          }
        }
      },
      "CreatePayeeRequest": {
        "allOf": [
          {
            "$ref": "#/components/schemas/CreateBeneficiaryRequest"
          },
          {
            "type": "object",
            "properties": {
              "scheme": {
                "type": "string",
                "enum": ["iban", "uk_account", "us_account", "swift"]
              }
            }
          }
        ]
      },
      "UpdateBeneficiaryRequest": {
        "type": "object",
        "description": "Partial update. Omitted fields keep their value.",
        "properties": {
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": ["individual", "business"]
          },
          "iban": {
            "type": "string",
            "description": "ISO 13616. Spaces are removed and letters upper-cased; mod-97 must pass."
          },
          "bic": {
            "type": "string"
          },
          "account_number": {
            "type": "string"
          },
          "routing_number": {
            "type": "string"
          },
          "bank_name": {
            "type": "string"
          },
          "bank_country": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "notes": {
            "type": "string"
          },
          "address_line1": {
            "type": "string"
          },
          "address_line2": {
            "type": "string"
          },
          "city": {
            "type": "string"
          },
          "postal_code": {
            "type": "string"
          },
          "country": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "currencies": {
            "type": "string"
          }
        }
      },
      "BeneficiaryError": {
        "type": "object",
        "required": ["error"],
        "description": "Stable error codes for beneficiary endpoints (BR-EF-023).\n400: invalid_id, invalid_type, invalid_iban, invalid_contact_id,\nname_required, account_required. 403: forbidden, forbidden_role,\nread_only_session. 404: not_found. 409: beneficiary_duplicate.\nPayees only: 400 invalid_scheme, 409 last_account, 409\npayee_changed and 400 invalid_expected_accounts (DELETE\n/payees/{payeeId} with expected_accounts).\nAdmin and service callers can also get legacy free-text 400 messages\n(missing customer_id or tenant_id, missing list filter).\n",
        "properties": {
          "error": {
            "type": "string",
            "enum": [
              "invalid_id",
              "invalid_type",
              "invalid_iban",
              "invalid_contact_id",
              "name_required",
              "account_required",
              "forbidden",
              "forbidden_role",
              "read_only_session",
              "not_found",
              "beneficiary_duplicate",
              "last_account",
              "invalid_scheme",
              "payee_changed",
              "invalid_expected_accounts"
            ]
          }
        }
      },
      "KamAssignment": {
        "type": "object",
        "description": "KAM-to-customer assignment (BR-AP-021)",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "kam_user_id": {
            "type": "string",
            "format": "uuid"
          },
          "customer_id": {
            "type": "string",
            "format": "uuid"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid"
          },
          "assigned_by": {
            "type": "string",
            "description": "Admin user ID who created the assignment"
          },
          "notes": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "OpsQueueRow": {
        "type": "object",
        "description": "One row of the Ops queue (GET /api/v1/ops-queue).",
        "properties": {
          "count": {
            "type": "integer"
          },
          "oldest_at": {
            "type": ["string", "null"],
            "format": "date-time"
          }
        }
      },
      "ApprovalRequest": {
        "type": "object",
        "description": "Transfer approval request requiring 4-eyes sign-off (F-02)",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid"
          },
          "customer_id": {
            "type": "string",
            "format": "uuid"
          },
          "debit_account_id": {
            "type": "string",
            "description": "Hex-encoded ledger debit account"
          },
          "credit_account_id": {
            "type": "string",
            "description": "Hex-encoded ledger credit account"
          },
          "amount": {
            "type": "integer",
            "format": "int64"
          },
          "currency": {
            "type": "string"
          },
          "ledger": {
            "type": "integer"
          },
          "transfer_code": {
            "type": "integer"
          },
          "description": {
            "type": "string"
          },
          "event_type": {
            "type": "string"
          },
          "workflow_id": {
            "type": "string"
          },
          "correlation_id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending_review",
              "approved",
              "rejected",
              "expired",
              "failed"
            ]
          },
          "fee_amount": {
            "type": "integer",
            "format": "int64",
            "description": "Fee leg calculated at request time (DEC-0038, 0.31.0); the execution posts it unchanged. 0 on approvals from before 0.31.0, which execute without a fee."
          },
          "charge_bearer": {
            "type": "string",
            "enum": ["slev", "sha", "our", "ben", ""],
            "description": "Bearer stored at request time; \"\" for internal and FPS and on older approvals. Only `ben` (SWIFT) takes the fee off the amount."
          },
          "requested_by_type": {
            "type": "string",
            "enum": ["staff", "customer", "service", ""],
            "description": "Who made the transfer (migration 268); \"\" on approvals from before 268."
          },
          "requested_by": {
            "type": "string",
            "description": "Staff user id or customer id of the maker; \"\" for a service or an older approval. A staff maker never approves their own transfer."
          },
          "dispatch_status": {
            "type": "string",
            "enum": [
              "dispatched",
              "dispatch_failed",
              "linked",
              "expired_legacy",
              ""
            ],
            "description": "Hand-off of an approved transfer to the executor (migration 268):\n`linked` was found posted (by its approval_id, migration 301) and linked;\n`expired_legacy` was approved before 268 and never executed (not\nre-sendable, the customer submits again).\n"
          },
          "dispatch_error": {
            "type": "string"
          },
          "redispatchable": {
            "type": "boolean",
            "description": "Approved, unexecuted, and its hand-off failed (recorded, dispatched 15 minutes ago without execution, or never recorded 15 minutes after approval); POST /approvals/{id}/dispatch sends it again."
          },
          "transfer_id": {
            "type": "string",
            "description": "Hex-encoded TB transfer ID, set after execution",
            "nullable": true
          },
          "reviewer_id": {
            "type": "string",
            "nullable": true
          },
          "reviewed_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "review_note": {
            "type": "string",
            "nullable": true
          },
          "reject_reason": {
            "type": "string",
            "nullable": true
          },
          "expires_at": {
            "type": ["string", "null"],
            "format": "date-time",
            "description": "While waiting (pending_review), 72 hours after it was made, when the executor expires it; null otherwise."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "payee_name": {
            "type": "string",
            "description": "Creditor name the request named (migration 293); \"\" for an internal transfer or an approval from before 293."
          },
          "payee_iban": {
            "type": "string",
            "description": "Destination IBAN the request named, upper case without spaces (293); \"\" when none (a malformed IBAN is refused, 400 payee_required)."
          },
          "payee_bic": {
            "type": "string",
            "description": "Destination BIC (293)."
          },
          "payee_account_number": {
            "type": "string",
            "description": "A non-IBAN destination account number (293)."
          },
          "rail": {
            "type": "string",
            "description": "The rail POST /transfers resolved (internal, sepa_sct, sepa_inst, sic, sic_ip, swift, fps); \"\" before 293."
          },
          "reference": {
            "type": "string",
            "description": "The customer's reference of the request (migration 301); the executed record carries it."
          },
          "counterparty_name": {
            "type": "string",
            "description": "The counterparty the request named (301)."
          },
          "beneficiary_id": {
            "type": "string",
            "description": "The saved payee the request was bound to (301); \"\" for none."
          },
          "screening_result_id": {
            "type": "string",
            "description": "The beneficiary's latest screening result when the request was screened (301); \"\" for none."
          },
          "screening_verdict": {
            "type": "string",
            "description": "The transfer-path screening result at request time (live_clear, skip_fresh, no_subject, not_applicable, tenant_disabled, error, ...; 301); \"\" before 301."
          },
          "acknowledged_at": {
            "type": "string",
            "description": "When the bank's Ops desk acknowledged a failed approval (301); \"\" while it waits on the queue."
          },
          "acknowledged_by": {
            "type": "string",
            "description": "The staff member who acknowledged it (301)."
          },
          "acknowledged_reason": {
            "type": "string",
            "description": "What was done, as the staff member wrote it (301)."
          },
          "customer_name": {
            "type": "string",
            "description": "The customer's name (\"\" when none). This and the account and\ncredit-customer names below are staff reads only: a customer's\nown GET /approvals/customer/{customerId} does not carry them.\n"
          },
          "debit_account_name": {
            "type": "string",
            "description": "Name of the debit account."
          },
          "debit_account_iban": {
            "type": "string",
            "description": "IBAN of the debit account."
          },
          "credit_account_name": {
            "type": "string",
            "description": "Name of the credit account (\"\" for the platform's account of a payment to another bank)."
          },
          "credit_account_iban": {
            "type": "string"
          },
          "credit_customer_name": {
            "type": "string",
            "description": "The credited account's customer, for an internal transfer."
          }
        }
      },
      "ReportJob": {
        "type": "object",
        "description": "Async report generation job (F-13)",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "report_type": {
            "type": "string",
            "enum": ["transaction_export", "customer_export", "audit_export"]
          },
          "format": {
            "type": "string",
            "enum": ["csv", "pdf"],
            "description": "csv; `pdf` only on older jobs, whose file is CSV as well"
          },
          "status": {
            "type": "string",
            "enum": ["queued", "processing", "completed", "failed"]
          },
          "filters": {
            "type": "object",
            "description": "Filter parameters passed to the report generator"
          },
          "s3_key": {
            "type": "string",
            "nullable": true,
            "description": "S3 object key for the generated file"
          },
          "file_size_bytes": {
            "type": "integer",
            "format": "int64",
            "nullable": true
          },
          "row_count": {
            "type": "integer",
            "nullable": true
          },
          "error_message": {
            "type": "string",
            "nullable": true
          },
          "workflow_id": {
            "type": "string",
            "nullable": true,
            "description": "Workflow engine execution ID"
          },
          "requested_by": {
            "type": "string",
            "description": "Admin user ID"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "started_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "completed_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "The job's bank (the workflow exports for it only); null for a job created without one"
          },
          "requested_by_user_id": {
            "type": "string",
            "nullable": true,
            "description": "The staff user whose session created the job; null before migration 257"
          },
          "requested_by_role": {
            "type": "string",
            "nullable": true,
            "description": "That session's effective role at request time; it decides the KAM scope of the export"
          }
        }
      },
      "TbAccount": {
        "type": "object",
        "description": "Ledger engine account (raw ledger representation)",
        "properties": {
          "id": {
            "type": "string",
            "description": "Account ID as decimal string (u128)"
          },
          "debits_pending": {
            "type": "string",
            "description": "Pending debit amount (minor units)"
          },
          "debits_posted": {
            "type": "string",
            "description": "Posted debit amount (minor units)"
          },
          "credits_pending": {
            "type": "string",
            "description": "Pending credit amount (minor units)"
          },
          "credits_posted": {
            "type": "string",
            "description": "Posted credit amount (minor units)"
          },
          "user_data_128": {
            "type": "string",
            "description": "Tenant/customer correlation ID"
          },
          "user_data_64": {
            "type": "integer"
          },
          "user_data_32": {
            "type": "integer"
          },
          "ledger": {
            "type": "integer",
            "description": "Ledger ID (currency code",
            "e.g. 978 for EUR)": null
          },
          "code": {
            "type": "integer",
            "description": "Account type code"
          },
          "flags": {
            "type": "integer"
          },
          "timestamp": {
            "type": "integer",
            "format": "int64",
            "description": "Nanosecond Unix timestamp"
          },
          "balance": {
            "type": "string",
            "description": "Available balance (credits_posted - debits_posted - debits_pending)"
          }
        }
      },
      "TbTransfer": {
        "type": "object",
        "description": "Ledger engine transfer (raw ledger representation)",
        "properties": {
          "id": {
            "type": "string",
            "description": "Transfer ID as decimal string (u128)"
          },
          "debit_account_id": {
            "type": "string",
            "description": "Debit account ID as decimal string"
          },
          "credit_account_id": {
            "type": "string",
            "description": "Credit account ID as decimal string"
          },
          "amount": {
            "type": "string",
            "description": "Transfer amount in minor units"
          },
          "pending_id": {
            "type": "string",
            "description": "Pending transfer ID for two-phase transfers"
          },
          "user_data_128": {
            "type": "string"
          },
          "user_data_64": {
            "type": "integer"
          },
          "user_data_32": {
            "type": "integer"
          },
          "timeout": {
            "type": "integer"
          },
          "ledger": {
            "type": "integer"
          },
          "code": {
            "type": "integer"
          },
          "flags": {
            "type": "integer"
          },
          "timestamp": {
            "type": "integer",
            "format": "int64",
            "description": "Nanosecond Unix timestamp"
          }
        }
      },
      "TbAccountBalance": {
        "type": "object",
        "description": "Historical balance snapshot for a ledger account",
        "properties": {
          "debits_pending": {
            "type": "string"
          },
          "debits_posted": {
            "type": "string"
          },
          "credits_pending": {
            "type": "string"
          },
          "credits_posted": {
            "type": "string"
          },
          "timestamp": {
            "type": "integer",
            "format": "int64",
            "description": "Nanosecond Unix timestamp"
          },
          "net_balance": {
            "type": "string",
            "description": "credits_posted minus debits_posted"
          }
        }
      },
      "Sar": {
        "type": "object",
        "description": "Suspicious Activity Report for the national Financial Intelligence Unit",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid"
          },
          "subject_type": {
            "type": "string",
            "enum": ["customer", "tenant"]
          },
          "subject_id": {
            "type": "string",
            "format": "uuid"
          },
          "narrative": {
            "type": "string",
            "description": "Full narrative describing the suspicious activity"
          },
          "linked_transactions": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Transfer UUIDs linked to this SAR"
          },
          "start_date": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "end_date": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "locked",
              "submitted",
              "acknowledged",
              "withdrawn"
            ]
          },
          "created_by": {
            "type": "string"
          },
          "created_by_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "edited_by_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Officers other than the author who edited the draft; none of them locks or files it."
          },
          "locked_by": {
            "type": "string",
            "nullable": true
          },
          "locked_by_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "locked_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "submitted_by": {
            "type": "string",
            "nullable": true,
            "description": "Who recorded the filing."
          },
          "filed_by_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "The staff id of who recorded the filing."
          },
          "filed_on": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "filing_channel": {
            "type": "string",
            "nullable": true
          },
          "withdrawn_by": {
            "type": "string",
            "nullable": true
          },
          "withdrawn_by_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "withdrawn_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "withdrawal_rationale": {
            "type": "string",
            "nullable": true
          },
          "no_case_reason": {
            "type": "string",
            "nullable": true,
            "description": "Why the report has no case (migration 299); null on a report with a case or written before 299."
          },
          "retention_until": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "detected_at": {
            "type": "string",
            "format": "date-time",
            "description": "The linked case's opening, else the draft's creation."
          },
          "due_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "detected_at + the jurisdiction's sar_sla_hours."
          },
          "overdue": {
            "type": "boolean",
            "description": "Not filed and past due_at."
          },
          "hold": {
            "type": "object",
            "nullable": true,
            "properties": {
              "status": {
                "type": "string"
              },
              "release_at": {
                "type": "string",
                "format": "date-time"
              }
            }
          },
          "submitted_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "reference_number": {
            "type": "string",
            "nullable": true,
            "description": "The FIU's reference of the (first) filing."
          },
          "filings": {
            "type": "array",
            "description": "The report's filings, one per channel (finance_compliance_filing).",
            "items": {
              "type": "object",
              "properties": {
                "channel": {
                  "type": "string"
                },
                "status": {
                  "type": "string"
                },
                "filed_on": {
                  "type": ["string", "null"],
                  "format": "date"
                },
                "reference": {
                  "type": ["string", "null"]
                },
                "filed_by": {
                  "type": ["string", "null"]
                },
                "submitted_at": {
                  "type": ["string", "null"],
                  "format": "date-time"
                }
              }
            }
          },
          "open_channels": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Channels of the case's filing drafts nobody filed yet (a CH report goes to MROS and to SECO)."
          },
          "local_today": {
            "type": "string",
            "format": "date",
            "description": "Today in the bank's time zone (the latest filing date)."
          },
          "case_status": {
            "type": "string",
            "nullable": true,
            "description": "The linked case's status (null without a case)."
          },
          "case_type": {
            "type": "string",
            "nullable": true,
            "description": "The linked case's type (null without a case)."
          },
          "subject_name": {
            "type": "string",
            "nullable": true,
            "description": "The customer's name (a customer report of the tenant), else null."
          },
          "subject_customer_type": {
            "type": "string",
            "nullable": true,
            "description": "individual or business (a customer report), else null."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "predicate": {
            "type": "string",
            "enum": [
              "fraud",
              "money_laundering",
              "terrorist_financing",
              "sanctions_evasion",
              "other"
            ],
            "description": "FRAML typology. MLRO sets it. Do not infer from amounts."
          }
        }
      },
      "SarCreateRequest": {
        "type": "object",
        "required": ["subject_type", "subject_id", "narrative", "predicate"],
        "properties": {
          "subject_type": {
            "type": "string",
            "enum": ["customer", "tenant"]
          },
          "subject_id": {
            "type": "string",
            "format": "uuid"
          },
          "narrative": {
            "type": "string",
            "description": "Full narrative describing the suspicious activity"
          },
          "predicate": {
            "type": "string",
            "enum": [
              "fraud",
              "money_laundering",
              "terrorist_financing",
              "sanctions_evasion",
              "other"
            ]
          },
          "linked_transactions": {
            "type": "array",
            "maxItems": 200,
            "description": "The payments the report covers (transfer ids, 32 hex digits or a uuid), all of the report's customer in this tenant.",
            "items": {
              "type": "string",
              "pattern": "^([0-9a-fA-F]{32}|[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$"
            }
          },
          "start_date": {
            "type": "string",
            "format": "date"
          },
          "end_date": {
            "type": "string",
            "format": "date"
          },
          "no_case_reason": {
            "type": "string",
            "minLength": 10,
            "maxLength": 2000,
            "description": "Why the report has no case. Required on a draft without case_id; refused with one."
          }
        }
      },
      "SarUpdateRequest": {
        "type": "object",
        "description": "Updatable fields on a draft SAR",
        "properties": {
          "narrative": {
            "type": "string"
          },
          "predicate": {
            "type": "string",
            "enum": [
              "fraud",
              "money_laundering",
              "terrorist_financing",
              "sanctions_evasion",
              "other"
            ]
          },
          "linked_transactions": {
            "type": "array",
            "maxItems": 200,
            "description": "The payments the report covers (transfer ids, 32 hex digits or a uuid), all of the report's customer in this tenant.",
            "items": {
              "type": "string",
              "pattern": "^([0-9a-fA-F]{32}|[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$"
            }
          },
          "start_date": {
            "type": "string",
            "format": "date"
          },
          "end_date": {
            "type": "string",
            "format": "date"
          },
          "no_case_reason": {
            "type": "string",
            "minLength": 10,
            "maxLength": 2000,
            "description": "Why the report has no case. Required on a draft without case_id; refused with one."
          }
        }
      },
      "SarCustomerCard": {
        "type": "object",
        "description": "The customer a report is about, as the SAR desk shows it.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": ["string", "null"]
          },
          "type": {
            "type": "string",
            "description": "individual or business"
          },
          "status": {
            "type": "string"
          },
          "country": {
            "type": ["string", "null"]
          },
          "nationality": {
            "type": ["string", "null"]
          },
          "date_of_birth": {
            "type": ["string", "null"],
            "format": "date"
          },
          "customer_since": {
            "type": "string",
            "format": "date-time"
          },
          "kyc_status": {
            "type": ["string", "null"]
          },
          "kyc_verified_at": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "risk_level": {
            "type": "string"
          },
          "risk_score": {
            "type": ["integer", "null"]
          },
          "screening_status": {
            "type": "string"
          },
          "frozen": {
            "type": "boolean",
            "description": "An account of the customer is frozen"
          },
          "accounts": {
            "type": "integer",
            "description": "Accounts not closed"
          }
        }
      },
      "SarPayment": {
        "type": "object",
        "description": "One payment of the report's customer, from the customer's side.",
        "properties": {
          "id": {
            "type": "string",
            "description": "Transfer id (32 hex digits)"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "value_date": {
            "type": ["string", "null"],
            "format": "date"
          },
          "amount": {
            "type": "integer",
            "format": "int64",
            "description": "Minor units",
            "unsigned": null
          },
          "currency": {
            "type": "string"
          },
          "direction": {
            "type": "string",
            "enum": ["in", "out"]
          },
          "counterparty": {
            "type": ["string", "null"]
          },
          "reference": {
            "type": ["string", "null"]
          },
          "status": {
            "type": "string"
          },
          "type": {
            "type": ["string", "null"]
          },
          "rail": {
            "type": ["string", "null"]
          }
        }
      },
      "SarCaseSummary": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "case_type": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "disposition": {
            "type": ["string", "null"]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "closed_at": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "due_at": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "assigned_to": {
            "type": ["string", "null"]
          },
          "opened_by": {
            "type": ["string", "null"]
          },
          "pending_sar": {
            "type": "boolean",
            "description": "A draft or locked report links the case"
          }
        }
      },
      "SarPriorReport": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string"
          },
          "predicate": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "created_by": {
            "type": "string"
          },
          "created_by_id": {
            "type": ["string", "null"],
            "format": "uuid"
          },
          "filed_on": {
            "type": ["string", "null"],
            "format": "date"
          },
          "reference_number": {
            "type": ["string", "null"]
          },
          "withdrawn_at": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "case_id": {
            "type": ["string", "null"],
            "format": "uuid"
          }
        }
      },
      "SarContext": {
        "type": "object",
        "properties": {
          "customer": {
            "$ref": "#/components/schemas/SarCustomerCard"
          },
          "open_cases": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SarCaseSummary"
            }
          },
          "prior_sars": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SarPriorReport"
            }
          },
          "transactions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SarPayment"
            }
          },
          "more": {
            "type": "boolean",
            "description": "The period holds more than 100 payments"
          }
        }
      },
      "SarEvidence": {
        "type": "object",
        "properties": {
          "sar_id": {
            "type": "string",
            "format": "uuid"
          },
          "customer": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/SarCustomerCard"
              },
              {
                "type": "null"
              }
            ]
          },
          "case": {
            "type": ["object", "null"],
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "case_type": {
                "type": "string"
              },
              "status": {
                "type": "string"
              },
              "disposition": {
                "type": ["string", "null"]
              },
              "rationale": {
                "type": ["string", "null"]
              },
              "source_ref": {
                "type": ["string", "null"]
              },
              "opened_by": {
                "type": ["string", "null"]
              },
              "assigned_to": {
                "type": ["string", "null"]
              },
              "closed_by": {
                "type": ["string", "null"]
              },
              "created_at": {
                "type": "string",
                "format": "date-time"
              },
              "closed_at": {
                "type": ["string", "null"],
                "format": "date-time"
              },
              "due_at": {
                "type": ["string", "null"],
                "format": "date-time"
              },
              "freeze_until": {
                "type": ["string", "null"],
                "format": "date-time"
              },
              "freeze_live": {
                "type": "boolean"
              }
            }
          },
          "case_evidence": {
            "type": "object",
            "description": "What opened the case and its subject summary, as on the case (`evidence`, `subject_summary`)."
          },
          "transactions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SarPayment"
            }
          },
          "transactions_named": {
            "type": "integer",
            "description": "Payments the report names (a payment no longer readable is counted, not listed)"
          },
          "alerts": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "source": {
                  "type": "string",
                  "enum": ["sanctions", "kyc", "cdd", "transfer"]
                },
                "alert_id": {
                  "type": "string",
                  "format": "uuid"
                },
                "severity": {
                  "type": "string"
                },
                "created_at": {
                  "type": "string",
                  "format": "date-time"
                },
                "assigned_to": {
                  "type": ["string", "null"]
                },
                "resolved_by": {
                  "type": ["string", "null"]
                },
                "resolved_at": {
                  "type": ["string", "null"],
                  "format": "date-time"
                },
                "outcome": {
                  "type": ["string", "null"]
                },
                "alert_type": {
                  "type": ["string", "null"]
                },
                "typology": {
                  "type": ["string", "null"]
                },
                "matched_name": {
                  "type": ["string", "null"]
                },
                "check_type": {
                  "type": ["string", "null"]
                }
              }
            }
          },
          "prior_sars": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SarPriorReport"
            }
          },
          "other_cases": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SarCaseSummary"
            }
          }
        }
      },
      "KybCase": {
        "type": "object",
        "description": "AI KYB verification case (BR-EF-013)",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid"
          },
          "customer_id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "enum": [
              "document_pending",
              "document_received",
              "extraction_running",
              "screening_running",
              "pending_review",
              "approved",
              "rejected"
            ]
          },
          "created_by": {
            "type": "string"
          },
          "assigned_to": {
            "type": "string",
            "nullable": true
          },
          "extracted_entities": {
            "type": "object",
            "nullable": true,
            "description": "AI-extracted KYB entities (company name, directors, UBOs)"
          },
          "screening_result": {
            "type": "object",
            "nullable": true,
            "description": "UBO sanctions screening result"
          },
          "ai_suggestion": {
            "type": "string",
            "enum": ["approve", "reject", "escalate"],
            "nullable": true,
            "description": "The workflow's suggestion; never a decision"
          },
          "decision": {
            "type": "string",
            "enum": ["approve", "reject", "escalate"],
            "nullable": true,
            "description": "The officer's decision"
          },
          "decision_reason": {
            "type": "string",
            "nullable": true
          },
          "decided_by": {
            "type": "string",
            "nullable": true,
            "description": "The officer who decided (session email)"
          },
          "decided_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "completed_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "KycScreeningLogEntry": {
        "type": "object",
        "description": "AML screening operation audit record",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "operation": {
            "type": "string",
            "enum": [
              "search",
              "person_details",
              "add_monitoring",
              "remove_monitoring",
              "list_monitoring",
              "add_blacklist",
              "remove_blacklist",
              "list_blacklist"
            ]
          },
          "provider": {
            "type": "string"
          },
          "performed_by": {
            "type": "string"
          },
          "performed_by_role": {
            "type": "string",
            "nullable": true
          },
          "request_params": {
            "type": "object"
          },
          "response_data": {
            "type": "object"
          },
          "subject_name": {
            "type": "string",
            "nullable": true
          },
          "match_count": {
            "type": "integer"
          },
          "highest_score": {
            "type": "number"
          },
          "result_summary": {
            "type": "string",
            "nullable": true
          },
          "customer_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "MonthlyStatement": {
        "type": "object",
        "description": "Monthly account statement record (customer Documents area)",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "wallet_id": {
            "type": "string",
            "format": "uuid"
          },
          "customer_id": {
            "type": "string",
            "format": "uuid"
          },
          "period_year": {
            "type": "integer"
          },
          "period_month": {
            "type": "integer"
          },
          "currency": {
            "type": "string"
          },
          "opening_balance": {
            "type": "string"
          },
          "closing_balance": {
            "type": "string"
          },
          "money_in": {
            "type": "string"
          },
          "money_out": {
            "type": "string"
          },
          "transaction_count": {
            "type": "integer"
          },
          "status": {
            "type": "string"
          },
          "file_format": {
            "type": "string"
          },
          "delivery_channel": {
            "type": "string"
          },
          "s3_key": {
            "type": "string"
          },
          "file_size_bytes": {
            "type": "integer"
          },
          "workflow_id": {
            "type": "string"
          },
          "error_message": {
            "type": "string"
          },
          "generated_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "DocumentError": {
        "type": "object",
        "required": ["error"],
        "properties": {
          "error": {
            "type": "object",
            "required": ["code", "message"],
            "properties": {
              "code": {
                "type": "string",
                "description": "`invalid_id`, `invalid_filter`, `invalid_cursor`,\n`invalid_period`, `unsupported_format`, `too_many_rows`,\n`not_found`, `not_confirmable`, `busy`,\n`documents_unavailable`, `documents_failed`\n"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      },
      "StatementSummary": {
        "type": "object",
        "required": [
          "account_id",
          "currency",
          "from",
          "to",
          "opening_balance",
          "closing_balance",
          "money_in",
          "money_out",
          "count",
          "balance_basis",
          "other_booked"
        ],
        "properties": {
          "account_id": {
            "type": "string",
            "description": "Ledger account id"
          },
          "currency": {
            "type": "string",
            "example": "CHF"
          },
          "from": {
            "type": "string",
            "format": "date"
          },
          "to": {
            "type": "string",
            "format": "date"
          },
          "opening_balance": {
            "type": "integer",
            "format": "int64",
            "description": "Minor units; the posted balance at the start of `from` (ledger history; derived: closing_balance minus the period's booked net)"
          },
          "closing_balance": {
            "type": "integer",
            "format": "int64",
            "description": "Minor units; the posted balance at the end of `to` (ledger history; derived: the posted balance now minus the net of completed movements after `to`)"
          },
          "money_in": {
            "type": "integer",
            "format": "int64",
            "description": "Booked credits",
            "minor units": null
          },
          "money_out": {
            "type": "integer",
            "format": "int64",
            "description": "Booked debits",
            "minor units": null,
            "negative or 0": null
          },
          "count": {
            "type": "integer",
            "description": "Movement rows in the period, pending included; the \"Other booked movements\" row is not counted"
          },
          "balance_basis": {
            "type": "string",
            "enum": ["ledger", "derived"],
            "description": "`ledger`: opening and closing from the TigerBeetle history; `derived`: an account without the history flag (or a ledger without history, TB_MOCK), the posted balance now minus the recorded movements after `to`"
          },
          "other_booked": {
            "type": "integer",
            "format": "int64",
            "description": "Minor units the ledger moved in the period beyond the rows, shown as one \"Other booked movements\" row (0 when none)"
          },
          "periods": {
            "type": "array",
            "maxItems": 13,
            "description": "Only with `interval=week`: the ISO weeks of the period, oldest\nfirst (the first and the last cut to `from` and `to`). Opening\nof the first: `opening_balance`; of each next one: the previous\n`closing_balance`.\n",
            "items": {
              "$ref": "#/components/schemas/StatementPeriod"
            }
          }
        }
      },
      "StatementPeriod": {
        "type": "object",
        "required": ["from", "to", "money_in", "money_out", "closing_balance"],
        "properties": {
          "from": {
            "type": "string",
            "format": "date",
            "description": "First local day: a Monday, or `from` for the first week"
          },
          "to": {
            "type": "string",
            "format": "date",
            "description": "Last local day: a Sunday, or `to` for the last week"
          },
          "money_in": {
            "type": "integer",
            "format": "int64",
            "description": "Booked credits of the week, minor units"
          },
          "money_out": {
            "type": "integer",
            "format": "int64",
            "description": "Booked debits of the week, minor units, negative or 0"
          },
          "closing_balance": {
            "type": "integer",
            "format": "int64",
            "description": "Minor units at the end of the week: the opening plus money_in plus money_out"
          }
        }
      },
      "StatementSummaryList": {
        "type": "object",
        "required": ["from", "to", "accounts"],
        "properties": {
          "from": {
            "type": "string",
            "format": "date"
          },
          "to": {
            "type": "string",
            "format": "date"
          },
          "accounts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StatementSummary"
            }
          }
        }
      },
      "StatementPreferences": {
        "type": "object",
        "required": [
          "customer_id",
          "default_format",
          "signed_stamped_default",
          "monthly_delivery_enabled",
          "monthly_delivery_hour"
        ],
        "properties": {
          "customer_id": {
            "type": "string",
            "format": "uuid"
          },
          "default_format": {
            "type": "string",
            "enum": ["pdf", "csv", "xml-v12", "xml-v08", "xml-v02", "mt940"]
          },
          "signed_stamped_default": {
            "type": "boolean"
          },
          "monthly_delivery_enabled": {
            "type": "boolean"
          },
          "monthly_delivery_hour": {
            "type": "integer",
            "minimum": 0,
            "maximum": 23,
            "nullable": true
          }
        }
      },
      "SupportError": {
        "type": "object",
        "description": "Error body of every support route (ARCH-029a \u00a70.4).",
        "required": ["error"],
        "properties": {
          "error": {
            "type": "object",
            "required": ["code", "message"],
            "properties": {
              "code": {
                "type": "string",
                "description": "Stable code; the list per status is in ARCH-029a \u00a70.4.",
                "example": "too_long"
              },
              "message": {
                "type": "string",
                "description": "English, for logs; never shown to customers as is."
              },
              "field": {
                "type": "string",
                "description": "The request field at fault."
              },
              "limit": {
                "type": "integer",
                "description": "The limit that was exceeded."
              },
              "feature": {
                "type": "string"
              },
              "note": {
                "type": "string"
              },
              "allowed": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "`invalid_transition`: the transitions the caller may make."
              }
            }
          }
        },
        "example": {
          "error": {
            "code": "too_long",
            "message": "The message is longer than 4000 characters",
            "field": "body",
            "limit": 4000
          }
        }
      },
      "SupportCaseType": {
        "type": "string",
        "enum": [
          "question",
          "complaint",
          "dispute",
          "fraud",
          "card_lost",
          "data_request",
          "closure",
          "technical",
          "other"
        ]
      },
      "SupportCaseStatus": {
        "type": "string",
        "description": "Internal case state (ARCH-029a \u00a78). Never sent to customers.",
        "enum": [
          "new",
          "ai_handling",
          "queued",
          "assigned",
          "waiting_customer",
          "escalated",
          "resolved",
          "reopened",
          "closed"
        ]
      },
      "SupportCustomerStatus": {
        "type": "string",
        "description": "What the customer is told (ARCH-029a \u00a73.2). Clients show an unknown\nvalue as `waiting`. A compliance-routed case is only ever `waiting`\nor `assigned`.\n",
        "enum": [
          "idle",
          "ai",
          "ai_answering",
          "waiting",
          "assigned",
          "waiting_for_you",
          "resolved",
          "closed"
        ]
      },
      "SupportPriority": {
        "type": "string",
        "enum": ["low", "normal", "high", "urgent"]
      },
      "SupportAuthor": {
        "type": "string",
        "enum": ["customer", "ai", "agent", "system"]
      },
      "SupportMessageKind": {
        "type": "string",
        "description": "`text` for customer, AI and agent messages; `holding_reply` and\n`final_reply` for agent complaint replies; `resolution` for an\nagent's resolution (a ticket's, or the reason of a staff close); the\nothers are system messages that clients render from `kind` and\n`params`. `closed` carries `params.closed_by` `customer` (POST\n/thread/close: \"You closed this conversation.\") or `agent` (POST\n/cases/{caseId}/close: \"Closed by our team\"), none when the reopen\nwindow ran out; `reopened` carries `params.reopened_by` `agent` when\nstaff reopened the case (DEC-0033 amendment 2026-10-04).\n`message_received` (0.33.0, `POST /chats/{threadId}/messages` only)\nacknowledges a customer message while the thread waits for a\nperson: `params.expected_reply_by` (date-time or null: \"as soon as\nwe can\"). Clients that do not know a kind show nothing for a system\nmessage.\n",
        "enum": [
          "text",
          "holding_reply",
          "final_reply",
          "handoff_requested",
          "assigned",
          "resolved",
          "reopened",
          "closed",
          "complaint_registered",
          "resolution",
          "ticket_opened",
          "request_added",
          "request_submitted",
          "request_accepted",
          "request_not_accepted",
          "request_cancelled",
          "request_due_changed",
          "ticket_cancelled",
          "ticket_withdrawn",
          "complaint_withdrawn",
          "letter_issued",
          "message_received"
        ]
      },
      "SupportHandoffReason": {
        "type": "string",
        "description": "Allowed per trigger and routing in ARCH-029a \u00a711.4.",
        "enum": [
          "customer_request",
          "complaint",
          "fraud",
          "card_lost",
          "dispute",
          "data_protection",
          "closure",
          "legal",
          "vulnerability",
          "restricted_topic",
          "low_confidence",
          "out_of_scope",
          "repeated_failure",
          "ai_unavailable",
          "other"
        ]
      },
      "SupportHandoffTrigger": {
        "type": "string",
        "enum": ["button", "rule", "model", "system"]
      },
      "SupportOrigin": {
        "type": "string",
        "enum": ["customer", "ai_handoff", "agent"]
      },
      "SupportChannel": {
        "type": "string",
        "enum": ["in_app", "email", "phone", "letter", "in_person"]
      },
      "SupportGeneratedBy": {
        "type": "string",
        "enum": ["model", "template"]
      },
      "SupportStatutoryKind": {
        "type": "string",
        "description": "Statutory clock (ARCH-029a \u00a79.3).",
        "enum": [
          "es_payment_services",
          "es_general",
          "data_request",
          "tenant_policy",
          "none"
        ]
      },
      "SupportComplaintClock": {
        "type": "string",
        "description": "Customer-facing clock of a complaint acknowledgement.",
        "enum": ["payment_services", "general", "tenant"]
      },
      "SupportComplaintScope": {
        "type": "string",
        "enum": ["payment_services", "general"]
      },
      "SupportComplaintOutcome": {
        "type": "string",
        "enum": ["upheld", "partially_upheld", "rejected"]
      },
      "SupportComplaintOutcomeRecorded": {
        "type": "string",
        "description": "The outcome a complaint carries (ARCH-030 \u00a72); `withdrawn` only by a withdrawal, never in a final reply.",
        "enum": ["upheld", "partially_upheld", "rejected", "withdrawn"]
      },
      "SupportWithdrawalBy": {
        "type": "string",
        "enum": ["customer", "staff_on_written_request"]
      },
      "SupportSlaState": {
        "type": "string",
        "enum": ["none", "on_time", "due_soon", "breached", "paused"]
      },
      "SupportTimerKind": {
        "type": "string",
        "enum": [
          "first_response",
          "next_response",
          "resolution",
          "statutory_warning",
          "statutory_due",
          "ai_turn_deadline",
          "ai_idle",
          "auto_close",
          "request_reminder",
          "request_due"
        ]
      },
      "SupportCaseEventType": {
        "type": "string",
        "enum": [
          "opened",
          "assigned",
          "unassigned",
          "status",
          "classified",
          "escalated",
          "handoff",
          "complaint_registered",
          "holding_reply",
          "final_reply",
          "sla_warning",
          "sla_breach",
          "statutory_warning",
          "statutory_breach",
          "reopened",
          "closed",
          "register_event",
          "erased",
          "request_added",
          "request_submitted",
          "request_reviewed",
          "request_cancelled",
          "request_due_changed",
          "request_overdue",
          "file_uploaded",
          "file_quarantined",
          "ticket_cancelled",
          "ticket_withdrawn",
          "complaint_withdrawn",
          "resolution",
          "transferred",
          "watcher_added",
          "watcher_removed",
          "linked",
          "unlinked",
          "letter_issued",
          "letter_pending"
        ]
      },
      "SupportTaskStatus": {
        "type": "string",
        "enum": ["open", "done", "cancelled"]
      },
      "SupportTokenKind": {
        "type": "string",
        "description": "PII token kinds; a token is `[KIND_n]` (ARCH-029a \u00a711.2).",
        "enum": [
          "PERSON",
          "IBAN",
          "CARD",
          "ACCOUNT",
          "EMAIL",
          "PHONE",
          "NATIONAL_ID",
          "ADDRESS",
          "DOB",
          "BIC",
          "TX"
        ]
      },
      "SupportToken": {
        "type": "string",
        "pattern": "^\\[(PERSON|IBAN|CARD|ACCOUNT|EMAIL|PHONE|NATIONAL_ID|ADDRESS|DOB|BIC|TX)_[1-9][0-9]{0,4}\\]$",
        "example": "[PERSON_1]"
      },
      "SupportTraceKind": {
        "type": "string",
        "enum": [
          "prompt",
          "completion",
          "tool_call",
          "tool_result",
          "moderation"
        ]
      },
      "SupportReplyKind": {
        "type": "string",
        "enum": ["answer", "refusal", "clarify", "handoff"]
      },
      "SupportActionKind": {
        "type": "string",
        "description": "Open-screen actions. `open_statement` and `open_transaction` only for\nclients that declare them in `client_actions`.\n",
        "enum": [
          "open_send",
          "open_card_freeze",
          "open_insights",
          "open_statement",
          "open_transaction"
        ]
      },
      "SupportContextKind": {
        "type": "string",
        "enum": ["transaction", "card", "wallet", "bank_hold"]
      },
      "SupportMessageIntent": {
        "type": "string",
        "description": "0.28.1 (\"Discuss this transaction with AI\", ARCH-029a \u00a73.5): the\nquestion chip the customer tapped on a payment or card. Valid only\nwith a `context` of kind transaction, bank_hold or card (else 422\ninvalid_field `intent`); dropped silently with a context that is not\nthe customer's; stored on the message and never shown back. The AI\nturn maps it in every language: `unrecognised` hands off as fraud\nwithout a model call (rule `chip.unrecognised.v1`, high priority;\nthe queue `payments` for a transfer, `cards` for a card payment) and\nthe safe steps come first as a template AI message (freeze the card,\nnever share codes, a person from the brand reviews it here; no\noutcome or refund); `unexpected_credit` hands off as a dispute to\n`payments`; `ask_person` hands off as customer_request, the payment\nstays on the case; `proof` answers with `open_transaction` (when the\nclient declares it) and `freeze_card` with `open_card_freeze`;\n`what_is`, `paid_before`, `when_arrive` and `why_failed` go to the\nmodel with the payment as context. A `bank_hold` context (written\nfrom a hold notice) takes the restricted route whatever the chip; a\npayment the bank holds without the customer saying so is answered\nlike any payment (0.28.1), and only staff see the case's\n`flags.compliance_linked`. With a context that is not the\ncustomer's, an `intent` is 422 `invalid_field` `context.id` (0.28.1;\ndropped silently in the branch draft).\n",
        "enum": [
          "what_is",
          "paid_before",
          "unrecognised",
          "unexpected_credit",
          "ask_person",
          "proof",
          "when_arrive",
          "why_failed",
          "freeze_card"
        ]
      },
      "SupportRole": {
        "type": "string",
        "description": "risk_officer works the risk queue (ARCH-030 \u00a713).",
        "enum": [
          "support_agent",
          "support_lead",
          "sac_officer",
          "mlro",
          "risk_officer",
          "bank_admin",
          "auditor"
        ]
      },
      "SupportCaseKind": {
        "type": "string",
        "enum": ["chat", "ticket"]
      },
      "SupportTicketCategory": {
        "type": "string",
        "description": "Internal, never sent to customers (ARCH-030 \u00a72, \u00a712.1).",
        "enum": ["customer", "general", "kyc", "risk", "aml_rfi"]
      },
      "SupportTicketTopic": {
        "type": "string",
        "enum": [
          "account",
          "payments",
          "cards",
          "documents",
          "personal_data",
          "account_closure",
          "technical",
          "complaint",
          "other"
        ]
      },
      "SupportTicketStatus": {
        "type": "string",
        "description": "The customer ticket status, derived (ARCH-030 \u00a74.1).",
        "enum": [
          "open",
          "waiting_for_you",
          "in_progress",
          "resolved",
          "closed",
          "cancelled"
        ]
      },
      "SupportRequestKind": {
        "type": "string",
        "enum": ["answer", "documents", "confirm"]
      },
      "SupportRequestStatus": {
        "type": "string",
        "description": "Stored request status (staff).",
        "enum": ["pending", "submitted", "accepted", "rejected", "cancelled"]
      },
      "SupportDocumentType": {
        "type": "string",
        "enum": [
          "identity_document",
          "proof_of_address",
          "source_of_funds",
          "source_of_wealth",
          "bank_statement",
          "payslip",
          "tax_return",
          "employment_contract",
          "company_register_extract",
          "articles_of_association",
          "ubo_declaration",
          "financial_statements",
          "invoice",
          "contract",
          "receipt",
          "police_report",
          "power_of_attorney",
          "other"
        ]
      },
      "SupportReviewReason": {
        "type": "string",
        "enum": [
          "illegible",
          "incomplete",
          "expired",
          "too_old",
          "wrong_document",
          "name_mismatch",
          "address_mismatch",
          "not_certified",
          "other"
        ]
      },
      "SupportCloseReason": {
        "type": "string",
        "enum": ["resolved", "cancelled", "withdrawn", "complaint_withdrawn"]
      },
      "SupportResolutionCode": {
        "type": "string",
        "enum": [
          "answered",
          "documents_accepted",
          "done",
          "no_action_needed",
          "not_possible",
          "duplicate"
        ]
      },
      "SupportRetentionClass": {
        "type": "string",
        "enum": ["support", "complaint", "compliance", "cdd"]
      },
      "SupportTemplateStatus": {
        "type": "string",
        "enum": ["draft", "proposed", "approved", "archived"]
      },
      "SupportSlotType": {
        "type": "string",
        "enum": ["amount", "date", "text", "operation"]
      },
      "SupportLocale": {
        "type": "string",
        "enum": ["en", "es", "de", "pt", "ar"]
      },
      "SupportAiDisclosure": {
        "type": "object",
        "description": "Present exactly when `ai_generated` is true (AI disclosure; DEC-0025 option B).",
        "required": ["label_key", "generated_by"],
        "properties": {
          "label_key": {
            "type": "string",
            "enum": ["assistant.aiAnswer"]
          },
          "generated_by": {
            "$ref": "#/components/schemas/SupportGeneratedBy"
          }
        }
      },
      "SupportCitation": {
        "type": "object",
        "description": "A help article the AI answer used. Tool citations are internal.",
        "required": ["kind", "article_id", "title", "path"],
        "properties": {
          "kind": {
            "type": "string",
            "enum": ["help_article"]
          },
          "article_id": {
            "type": "string",
            "format": "uuid"
          },
          "title": {
            "type": "string"
          },
          "path": {
            "type": "string",
            "example": "/help/articles/transferencias-devueltas"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "nullable": true,
            "description": "The tenant's customer_portal_url plus path, or null."
          }
        }
      },
      "SupportAction": {
        "type": "object",
        "description": "Open-screen action (the money assistant's object). `label` is empty;\nclients name the screen from `kind`. Params: open_send\n`amount_minor`, `currency`; open_card_freeze `card_id`;\nopen_insights `section`, `month`; open_statement `account_id`,\n`period`; open_transaction `transfer_id`.\n",
        "required": ["kind", "label", "params"],
        "properties": {
          "kind": {
            "$ref": "#/components/schemas/SupportActionKind"
          },
          "label": {
            "type": "string",
            "enum": [""]
          },
          "params": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "SupportExpectedReply": {
        "type": "object",
        "required": ["within_minutes", "from"],
        "properties": {
          "within_minutes": {
            "type": "integer",
            "nullable": true,
            "description": "First-response target of the case's SLA policy (business minutes)."
          },
          "from": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Next opening of business hours when the desk is closed now (0.26.0 - the hours of l1, never the case's queue)."
          }
        }
      },
      "SupportComplaintAck": {
        "type": "object",
        "description": "Complaint acknowledgement. Dates are calendar dates in the bank's\n`time_zone`; clients show them as given, without conversion.\n",
        "required": [
          "reference",
          "registered_at",
          "clock",
          "reply_by",
          "time_zone"
        ],
        "properties": {
          "reference": {
            "type": "string",
            "example": "RC-2026-000017"
          },
          "registered_at": {
            "type": "string",
            "format": "date-time",
            "description": "The first message that expressed the complaint (or the tap, or the date an agent recorded)."
          },
          "clock": {
            "$ref": "#/components/schemas/SupportComplaintClock"
          },
          "reply_by": {
            "type": "string",
            "format": "date",
            "example": "2026-12-29"
          },
          "reply_by_latest": {
            "type": "string",
            "format": "date",
            "nullable": true,
            "description": "payment_services only; the one-month limit for a holding reply.",
            "example": "2027-01-04"
          },
          "time_zone": {
            "type": "string",
            "example": "Europe/Madrid"
          },
          "holding_reply_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "final_reply_by": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "final_reply_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "outcome": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportComplaintOutcomeRecorded"
              }
            ],
            "nullable": true
          },
          "withdrawn_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the customer withdrew the complaint (ARCH-030 \u00a74.4); then `outcome` is `withdrawn`."
          }
        }
      },
      "SupportMessage": {
        "type": "object",
        "description": "A message as the customer sees it. AI messages carry\n`ai_generated: true` and `ai_disclosure`; clients show the\n`assistant.aiAnswer` label on them. System messages have no body.\n",
        "required": [
          "id",
          "author",
          "kind",
          "body",
          "ai_generated",
          "ai_disclosure",
          "citations",
          "actions",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "client_message_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "Only on the customer's own messages."
          },
          "author": {
            "$ref": "#/components/schemas/SupportAuthor"
          },
          "kind": {
            "$ref": "#/components/schemas/SupportMessageKind"
          },
          "body": {
            "type": "string",
            "nullable": true,
            "description": "Plain text, at most 4000 characters (a final reply adds the\ntenant's escalation text of at most 1000). Null for system\nmessages.\n"
          },
          "params": {
            "type": "object",
            "nullable": true,
            "additionalProperties": true,
            "description": "handoff_requested `{expected_reply, availability, requested_by}`\n(`availability`: SupportAvailability at the handoff, or null;\n0.26.0; `requested_by` (0.26.1): `customer` when the customer\nasked for a person (the button or their own words), `bank` when\nthe bank passed the conversation on (the AI could not answer, a\nrule, a system handoff); never the reason. Absent on older\nmessages: clients do not claim the customer asked); assigned\n`{agent_display_name}`; resolved `{reopen_until}`;\ncomplaint_registered SupportComplaintAck fields; holding_reply\n`{reference, final_reply_by, time_zone}`; final_reply\n`{reference, outcome}`.\n"
          },
          "agent_display_name": {
            "type": "string",
            "nullable": true,
            "description": "Agent messages only (the operator identifies themselves)."
          },
          "ai_generated": {
            "type": "boolean"
          },
          "ai_disclosure": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportAiDisclosure"
              }
            ],
            "nullable": true
          },
          "citations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportCitation"
            }
          },
          "actions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportAction"
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SupportAvailabilityHours": {
        "type": "object",
        "description": "One opening interval and the ISO weekdays it applies to (1 = Monday). A split shift is two entries with the same days.",
        "required": ["days", "from", "to"],
        "properties": {
          "days": {
            "type": "array",
            "items": {
              "type": "integer",
              "minimum": 1,
              "maximum": 7
            },
            "example": [1, 2, 3, 4, 5]
          },
          "from": {
            "type": "string",
            "pattern": "^([01][0-9]|2[0-3]):[0-5][0-9]$",
            "example": "09:00"
          },
          "to": {
            "type": "string",
            "pattern": "^(([01][0-9]|2[0-3]):[0-5][0-9]|24:00)$",
            "example": "18:00"
          }
        }
      },
      "SupportAvailability": {
        "type": "object",
        "description": "When people of the bank answer (ARCH-029a \u00a73.1, 0.26.0). Always\ncomputed for the general queue `l1`, never for the queue of the\ncustomer's case (tipping-off); no names, no counts. Null when the\ntenant's `show_availability` is off. Clients show \"We're\navailable ...\" from `hours` in `zone` when `staffed_now` is false;\n\"Talk to a person\" is never hidden.\n",
        "required": ["staffed_now", "next_open_at", "hours", "zone"],
        "properties": {
          "staffed_now": {
            "type": "boolean",
            "description": "Inside the hours of l1 (no holiday, no closure) and at least one person who works l1 is available now."
          },
          "next_open_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "The next opening of l1 when it is closed now; null while it is open (also when nobody is available)."
          },
          "hours": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportAvailabilityHours"
            }
          },
          "zone": {
            "type": "string",
            "example": "Europe/Madrid"
          }
        }
      },
      "SupportAgentAvailability": {
        "type": "object",
        "required": [
          "status",
          "source",
          "changed_at",
          "last_seen_at",
          "counts_now"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": ["available", "away", "offline"]
          },
          "source": {
            "type": "string",
            "enum": ["self", "idle", "logout", "lead", "expired"]
          },
          "changed_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "last_seen_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "counts_now": {
            "type": "boolean",
            "description": "The person counts for staffing now (available, seen within 3 minutes, inside their own schedule if they have one)."
          }
        }
      },
      "SupportAvailabilityInput": {
        "type": "object",
        "required": ["status"],
        "properties": {
          "status": {
            "type": "string",
            "enum": ["available", "away", "offline"]
          },
          "source": {
            "type": "string",
            "enum": ["self", "idle", "logout"],
            "default": "self"
          }
        }
      },
      "SupportAgentPresence": {
        "type": "object",
        "required": [
          "user_id",
          "display_name",
          "role",
          "status",
          "source",
          "changed_at",
          "counts_now",
          "queues"
        ],
        "description": "A person in the team view (employee privacy): no\nlast_seen_at (it stays on GET /me/availability), and changed_at only\nto the minute, the desk's \"since\".\n",
        "properties": {
          "user_id": {
            "type": "string",
            "format": "uuid"
          },
          "display_name": {
            "type": "string"
          },
          "role": {
            "$ref": "#/components/schemas/SupportRole"
          },
          "status": {
            "type": "string",
            "enum": ["available", "away", "offline"]
          },
          "source": {
            "type": "string",
            "enum": ["self", "idle", "logout", "lead", "expired"]
          },
          "changed_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Since when the status holds, truncated to the minute."
          },
          "counts_now": {
            "type": "boolean"
          },
          "queues": {
            "type": "array",
            "description": "Codes of the listed queues this person works.",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "SupportQueueStaffing": {
        "type": "object",
        "required": [
          "code",
          "label",
          "open_now",
          "staffed_now",
          "available_agents",
          "next_open_at"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "open_now": {
            "type": "boolean",
            "description": "Inside the queue's effective hours, no holiday, no closure."
          },
          "staffed_now": {
            "type": "boolean"
          },
          "available_agents": {
            "type": "integer",
            "minimum": 0
          },
          "next_open_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "SupportPresence": {
        "type": "object",
        "required": ["agents", "queues", "generated_at"],
        "properties": {
          "agents": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportAgentPresence"
            }
          },
          "queues": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportQueueStaffing"
            }
          },
          "generated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SupportHoursInterval": {
        "type": "object",
        "required": ["weekday", "from", "to"],
        "properties": {
          "weekday": {
            "type": "integer",
            "minimum": 1,
            "maximum": 7,
            "description": "ISO weekday, 1 = Monday."
          },
          "from": {
            "type": "string",
            "pattern": "^([01][0-9]|2[0-3]):[0-5][0-9]$",
            "example": "09:00"
          },
          "to": {
            "type": "string",
            "pattern": "^(([01][0-9]|2[0-3]):[0-5][0-9]|24:00)$",
            "example": "18:00"
          }
        }
      },
      "SupportHoursInput": {
        "type": "object",
        "required": ["hours"],
        "properties": {
          "hours": {
            "type": "array",
            "maxItems": 28,
            "items": {
              "$ref": "#/components/schemas/SupportHoursInterval"
            }
          }
        }
      },
      "SupportHours": {
        "type": "object",
        "required": [
          "queue",
          "time_zone",
          "source",
          "hours",
          "closures",
          "open_now",
          "next_open_at"
        ],
        "properties": {
          "queue": {
            "type": "string",
            "description": "The queue code or `tenant`."
          },
          "time_zone": {
            "type": "string",
            "example": "Europe/Madrid"
          },
          "source": {
            "type": "string",
            "enum": ["queue", "tenant", "calendar"],
            "description": "Where the effective rows come from - the queue's own, the tenant's default, or the calendar's business_hours on its working_days."
          },
          "hours": {
            "type": "array",
            "description": "The effective weekly intervals, by weekday then start.",
            "items": {
              "$ref": "#/components/schemas/SupportHoursInterval"
            }
          },
          "closures": {
            "type": "array",
            "description": "Closures of this scope that have not ended (for a queue also the desk-wide ones).",
            "items": {
              "$ref": "#/components/schemas/SupportClosure"
            }
          },
          "open_now": {
            "type": "boolean"
          },
          "next_open_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "SupportClosure": {
        "type": "object",
        "required": [
          "id",
          "queue",
          "starts_at",
          "ends_at",
          "reason",
          "created_by",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "queue": {
            "type": "string",
            "nullable": true,
            "description": "Queue code; null for the whole desk."
          },
          "starts_at": {
            "type": "string",
            "format": "date-time"
          },
          "ends_at": {
            "type": "string",
            "format": "date-time"
          },
          "reason": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "created_by": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SupportClosureInput": {
        "type": "object",
        "required": ["starts_at", "ends_at", "reason"],
        "properties": {
          "queue": {
            "type": "string",
            "nullable": true,
            "description": "Queue code; null or absent for the whole desk."
          },
          "starts_at": {
            "type": "string",
            "format": "date-time"
          },
          "ends_at": {
            "type": "string",
            "format": "date-time"
          },
          "reason": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          }
        }
      },
      "SupportAvailabilityInternal": {
        "description": "SupportAvailability for the workflows (\u00a77.1, \u00a77.6), never null there, plus the hours line in the conversation language.",
        "allOf": [
          {
            "$ref": "#/components/schemas/SupportAvailability"
          },
          {
            "type": "object",
            "required": ["hours_line"],
            "properties": {
              "hours_line": {
                "type": "string",
                "nullable": true,
                "description": "\"We're available Mon\u2013Fri 09:00\u201318:00 (Madrid time).\" in the conversation language; null when show_availability is off or l1 has no hours."
              }
            }
          }
        ]
      },
      "SupportMessagePage": {
        "type": "object",
        "required": ["messages", "next_cursor", "has_more", "latest_cursor"],
        "properties": {
          "messages": {
            "type": "array",
            "description": "Oldest first.",
            "items": {
              "$ref": "#/components/schemas/SupportMessage"
            }
          },
          "next_cursor": {
            "type": "string",
            "nullable": true,
            "description": "`before` cursor for older messages."
          },
          "has_more": {
            "type": "boolean",
            "description": "Older messages exist."
          },
          "latest_cursor": {
            "type": "string",
            "nullable": true,
            "description": "`after` cursor of the newest message."
          },
          "has_more_newer": {
            "type": "boolean",
            "description": "`after` reads: more newer messages follow."
          }
        }
      },
      "SupportThread": {
        "type": "object",
        "description": "The customer's support thread (ARCH-029a \u00a73.1). Same body for GET /thread and POST /thread/handoff.",
        "required": [
          "id",
          "status",
          "ai_enabled",
          "disclosure_required",
          "disclosure_key",
          "unread",
          "csat",
          "messages",
          "next_cursor",
          "has_more"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "Null until the first message or handoff."
          },
          "status": {
            "$ref": "#/components/schemas/SupportCustomerStatus"
          },
          "ai_enabled": {
            "type": "boolean",
            "description": "The AI answers the next message (ARCH-029a \u00a72.3)."
          },
          "disclosure_required": {
            "type": "boolean",
            "description": "ai_enabled or any AI message in the thread; clients show the assistant.disclosure line at the top."
          },
          "disclosure_key": {
            "type": "string",
            "enum": ["assistant.disclosure"]
          },
          "language": {
            "type": "string",
            "nullable": true,
            "example": "es"
          },
          "time_zone": {
            "type": "string",
            "example": "Europe/Madrid",
            "description": "The bank's calendar zone (IANA); the customer's conversation export writes its times in it (DEC-0033 decision 24)."
          },
          "case_reference": {
            "type": "string",
            "nullable": true,
            "example": "SR-2026-000412"
          },
          "assignee": {
            "type": "object",
            "nullable": true,
            "required": ["display_name"],
            "properties": {
              "display_name": {
                "type": "string"
              }
            }
          },
          "expected_reply": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportExpectedReply"
              }
            ],
            "nullable": true
          },
          "unread": {
            "type": "integer",
            "minimum": 0
          },
          "reopen_until": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "complaint": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportComplaintAck"
              }
            ],
            "nullable": true
          },
          "can": {
            "type": "object",
            "description": "What the customer may do in the thread (ARCH-030 \u00a75.10, \u00a74.5).",
            "required": ["withdraw_complaint", "close"],
            "properties": {
              "withdraw_complaint": {
                "type": "boolean",
                "description": "The open complaint can be withdrawn (POST /thread/complaint/withdraw) - registered, no final reply, case not closed."
              },
              "close": {
                "type": "boolean",
                "description": "The open conversation can be ended (POST /thread/close) - a case that is not closed and not a complaint."
              }
            }
          },
          "resolution_prompt": {
            "type": "object",
            "nullable": true,
            "description": "0.27.0, DEC-0033 decision 29: \"Did that help?\" under this AI\nanswer, decided by the bank (the AI has an AI-only, non-complaint\nchat case, no turn pending, and its newest answer has no\nfeedback). Clients show it and never decide it.\n",
            "required": ["message_id"],
            "properties": {
              "message_id": {
                "type": "string",
                "format": "uuid"
              }
            }
          },
          "csat": {
            "type": "object",
            "required": ["asked", "score"],
            "properties": {
              "asked": {
                "type": "boolean"
              },
              "score": {
                "type": "integer",
                "minimum": 1,
                "maximum": 5,
                "nullable": true
              }
            }
          },
          "messages": {
            "type": "array",
            "description": "Newest page, oldest first.",
            "items": {
              "$ref": "#/components/schemas/SupportMessage"
            }
          },
          "next_cursor": {
            "type": "string",
            "nullable": true
          },
          "has_more": {
            "type": "boolean"
          },
          "latest_cursor": {
            "type": "string",
            "nullable": true
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "support_availability": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportAvailability"
              }
            ],
            "nullable": true
          }
        }
      },
      "SupportMessageContext": {
        "type": "object",
        "description": "Never shown to the customer. An id that is not the customer's is\ndropped (422 `invalid_field` `context.id` when the message carries an\n`intent`, 0.28.1). Stored with the kind the client sent: a payment\nthe bank holds, or that a compliance case names, stays\n`transaction` and takes the route of any payment (0.28.1; the hold guard of\nthe branch draft that turned it into `bank_hold` let a customer tell\nwhich payment was held). `bank_hold` is the client's word: the\ncustomer writes from a hold notice the app already shows. A card\npayment that is not a transfer (a card authorisation) is sent as\n`card` with the card id.\n",
        "required": ["kind"],
        "properties": {
          "kind": {
            "$ref": "#/components/schemas/SupportContextKind"
          },
          "id": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "SupportPostMessageRequest": {
        "type": "object",
        "required": ["client_message_id", "body"],
        "properties": {
          "client_message_id": {
            "type": "string",
            "format": "uuid"
          },
          "body": {
            "type": "string",
            "maxLength": 4000,
            "description": "ARCH-029a \u00a70.3: trimmed, NFC, 1 to 4000 characters."
          },
          "context": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportMessageContext"
              }
            ],
            "nullable": true
          },
          "intent": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportMessageIntent"
              }
            ],
            "nullable": true,
            "description": "0.28.1: the chip tapped with this context; requires `context` of the customer (else 422 `invalid_field` `context.id`, 0.28.1)."
          },
          "client_actions": {
            "type": "array",
            "description": "Action kinds the client renders. Absent means open_send, open_card_freeze, open_insights. Declare open_transaction to get the payment's screen on a `proof` chip.",
            "items": {
              "$ref": "#/components/schemas/SupportActionKind"
            }
          }
        },
        "example": {
          "client_message_id": "c3d1e2f0-1a2b-4c3d-8e9f-0a1b2c3d4e5f",
          "body": "Me hab\u00e9is cobrado dos veces la transferencia.",
          "context": {
            "kind": "transaction",
            "id": "00000000000000000000000000a1b2c3"
          }
        }
      },
      "SupportHandoffRequest": {
        "type": "object",
        "required": ["reason"],
        "properties": {
          "reason": {
            "type": "string",
            "enum": ["customer_request", "complaint"]
          }
        }
      },
      "SupportReadRequest": {
        "type": "object",
        "required": ["up_to"],
        "properties": {
          "up_to": {
            "type": "string",
            "format": "uuid",
            "description": "A message id of this thread."
          }
        }
      },
      "SupportCsatRequest": {
        "type": "object",
        "required": ["score"],
        "properties": {
          "score": {
            "type": "integer",
            "minimum": 1,
            "maximum": 5
          },
          "comment": {
            "type": "string",
            "maxLength": 500,
            "nullable": true
          }
        }
      },
      "SupportCsatResult": {
        "type": "object",
        "required": ["case_reference", "score"],
        "properties": {
          "case_reference": {
            "type": "string"
          },
          "score": {
            "type": "integer",
            "minimum": 1,
            "maximum": 5
          },
          "comment": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "SupportHelpArticleSummary": {
        "type": "object",
        "required": ["article_id", "slug", "title", "snippet", "path"],
        "properties": {
          "article_id": {
            "type": "string",
            "format": "uuid"
          },
          "slug": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "snippet": {
            "type": "string",
            "maxLength": 300
          },
          "path": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "nullable": true
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SupportHelpSearchResult": {
        "type": "object",
        "required": ["articles"],
        "properties": {
          "articles": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportHelpArticleSummary"
            }
          }
        }
      },
      "SupportHelpArticle": {
        "type": "object",
        "required": [
          "article_id",
          "slug",
          "locale",
          "title",
          "body",
          "version",
          "path"
        ],
        "properties": {
          "article_id": {
            "type": "string",
            "format": "uuid"
          },
          "slug": {
            "type": "string"
          },
          "locale": {
            "$ref": "#/components/schemas/SupportLocale"
          },
          "title": {
            "type": "string"
          },
          "body": {
            "type": "string"
          },
          "version": {
            "type": "integer"
          },
          "path": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "nullable": true
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SupportAgentProfile": {
        "type": "object",
        "required": ["user_id", "role", "display_name", "languages", "queues"],
        "properties": {
          "user_id": {
            "type": "string",
            "format": "uuid"
          },
          "role": {
            "$ref": "#/components/schemas/SupportRole"
          },
          "display_name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40,
            "description": "What customers see (first name or alias)."
          },
          "languages": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "queues": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["code", "label", "access"],
              "properties": {
                "code": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                },
                "access": {
                  "type": "string",
                  "enum": ["work", "read"]
                }
              }
            }
          }
        }
      },
      "SupportAgentProfilePatch": {
        "type": "object",
        "properties": {
          "display_name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40
          },
          "languages": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "SupportPersonRef": {
        "type": "object",
        "required": ["id", "display_name"],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "display_name": {
            "type": "string"
          }
        }
      },
      "SupportQueueRef": {
        "type": "object",
        "required": ["id", "code", "label"],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "code": {
            "type": "string",
            "example": "l1"
          },
          "label": {
            "type": "string"
          }
        }
      },
      "SupportCaseFlags": {
        "type": "object",
        "required": ["complaint", "data_request", "vulnerability"],
        "properties": {
          "complaint": {
            "type": "boolean"
          },
          "data_request": {
            "type": "boolean"
          },
          "vulnerability": {
            "type": "boolean"
          },
          "tipping_off_lock": {
            "type": "boolean",
            "description": "Sent only to mlro and auditor; other roles never see such a case."
          },
          "compliance_linked": {
            "type": "boolean",
            "description": "0.28.1, staff case views only (never the turn context or a customer view): the case's payment was under a compliance hold (a hold status or an open compliance case naming it; never the direct debit holding period the customer sees) when the customer wrote (the silent marker; DEC-0032 amendment 2026-10-04). The desk shows \"Linked to a compliance case: do not discuss holds with the customer\". The compliance case itself is a `case_links` entry of kind `compliance_case`, for mlro and auditor only. The marker is written off the request by the support held check job, within about a minute; `compliance_linked_transfers` names the payments. It lets the MLRO open and read the case, whatever its queue (still with the AI, l1, payments, cards), for 90 days after the newest marker, read only, only the marked case's messages, every read audited `via: held_payment_link` and hidden from other audit readers (DEC-0033 decision 31)."
          }
        }
      },
      "SupportCaseSla": {
        "type": "object",
        "required": ["state"],
        "properties": {
          "policy_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "first_response_due": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "next_response_due": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "resolution_due": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "next_due": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "The nearest unmet due instant."
          },
          "state": {
            "$ref": "#/components/schemas/SupportSlaState"
          },
          "paused_since": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "SupportCaseStatutory": {
        "type": "object",
        "required": ["kind", "due_date", "due_at", "time_zone", "state"],
        "properties": {
          "kind": {
            "$ref": "#/components/schemas/SupportStatutoryKind"
          },
          "clock_started_at": {
            "type": "string",
            "format": "date-time"
          },
          "due_date": {
            "type": "string",
            "format": "date"
          },
          "due_at": {
            "type": "string",
            "format": "date-time",
            "description": "End of due_date in time_zone."
          },
          "warning_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "reply_by_latest": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "time_zone": {
            "type": "string"
          },
          "state": {
            "$ref": "#/components/schemas/SupportSlaState"
          }
        }
      },
      "SupportCaseComplaint": {
        "type": "object",
        "required": ["reference", "registered_at", "scope"],
        "properties": {
          "reference": {
            "type": "string"
          },
          "registered_at": {
            "type": "string",
            "format": "date-time"
          },
          "registered_message_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "scope": {
            "$ref": "#/components/schemas/SupportComplaintScope"
          },
          "holding_reply_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "final_reply_by": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "final_reply_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "outcome": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportComplaintOutcomeRecorded"
              }
            ],
            "nullable": true
          },
          "supervisor_escalation_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "withdrawn_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "withdrawal_by": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportWithdrawalBy"
              }
            ],
            "nullable": true
          },
          "withdrawal_channel": {
            "type": "string",
            "enum": ["in_app", "email", "letter", "in_person"],
            "nullable": true
          },
          "withdrawal_letter": {
            "type": "string",
            "enum": ["issued", "pending"],
            "nullable": true,
            "description": "0.33.1. The confirmation letter of a withdrawn complaint (null: not withdrawn). `pending`: the withdrawal is recorded and the customer saw it confirmed; the letter follows once letters are available (DEC-0033 amendment 2026-10-06)."
          }
        }
      },
      "SupportCaseHandoff": {
        "type": "object",
        "required": ["reason", "trigger", "at"],
        "properties": {
          "reason": {
            "$ref": "#/components/schemas/SupportHandoffReason"
          },
          "trigger": {
            "$ref": "#/components/schemas/SupportHandoffTrigger"
          },
          "rule_id": {
            "type": "string",
            "nullable": true
          },
          "intent": {
            "type": "string",
            "nullable": true
          },
          "language": {
            "type": "string",
            "nullable": true
          },
          "summary": {
            "type": "string",
            "nullable": true,
            "description": "Re-identified for the viewer (generated on tokenised text)."
          },
          "facts_used": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          },
          "facts": {
            "type": "array",
            "description": "What the AI used, the traces `facts_used` names that are still kept, in that order. Kind and tool only, never the payload.",
            "items": {
              "type": "object",
              "required": ["kind", "tool", "at"],
              "properties": {
                "kind": {
                  "type": "string",
                  "enum": [
                    "prompt",
                    "completion",
                    "tool_call",
                    "tool_result",
                    "moderation"
                  ]
                },
                "tool": {
                  "type": "string",
                  "nullable": true
                },
                "at": {
                  "type": "string",
                  "format": "date-time"
                }
              }
            }
          },
          "at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SupportCaseCan": {
        "type": "object",
        "description": "What the viewer may do on this case; the console needs no role logic of its own.",
        "properties": {
          "withdraw_complaint_on_request": {
            "type": "boolean",
            "description": "ARCH-030 \u00a76.10 - the SAC officer (the MLRO on a locked complaint) who works the case; a complaint without a final reply, not closed."
          },
          "close": {
            "type": "boolean",
            "description": "ARCH-030 \u00a74.5 - POST /cases/{caseId}/close; not a complaint, not closed or AI-only; the assignee, the queue's manager, or any worker while unassigned."
          },
          "reopen": {
            "type": "boolean",
            "description": "ARCH-030 \u00a74.5 - POST /cases/{caseId}/reopen; resolved or closed, not a withdrawn complaint, no other open case in a chat conversation; complaints only their complaint officer."
          },
          "reply": {
            "type": "boolean"
          },
          "note": {
            "type": "boolean"
          },
          "assign": {
            "type": "boolean"
          },
          "take": {
            "type": "boolean"
          },
          "escalate": {
            "type": "boolean"
          },
          "resolve": {
            "type": "boolean"
          },
          "classify": {
            "type": "boolean"
          },
          "remove_complaint": {
            "type": "boolean"
          },
          "holding_reply": {
            "type": "boolean"
          },
          "final_reply": {
            "type": "boolean"
          },
          "add_request": {
            "type": "boolean",
            "description": "Tickets: the assignee of an open ticket."
          },
          "review": {
            "type": "boolean",
            "description": "Tickets: a submission waits for review."
          },
          "cancel_ticket": {
            "type": "boolean",
            "description": "Tickets: not a complaint; assignee or the queue's manager."
          },
          "change_due": {
            "type": "boolean",
            "description": "Tickets: an open request."
          },
          "transfer": {
            "type": "boolean",
            "description": "ARCH-030 \u00a77.1: the assignee, any worker while unassigned, the queue's manager; `escalate` is the same."
          },
          "watch": {
            "type": "boolean",
            "description": "Any role that may see the case but bank_admin and auditor."
          },
          "link": {
            "type": "boolean",
            "description": "Who works the case (ARCH-030 \u00a77.7)."
          }
        }
      },
      "SupportCaseSummary": {
        "type": "object",
        "required": [
          "id",
          "reference",
          "customer",
          "kind",
          "type",
          "priority",
          "status",
          "queue",
          "assignee",
          "origin",
          "channel",
          "language",
          "flags",
          "sla",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "reference": {
            "type": "string",
            "example": "SR-2026-000412"
          },
          "kind": {
            "$ref": "#/components/schemas/SupportCaseKind"
          },
          "ticket": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportTicketInfo"
              }
            ],
            "description": "Tickets only (absent on a chat case)."
          },
          "customer": {
            "type": "object",
            "required": ["id", "display_name"],
            "properties": {
              "id": {
                "type": "string"
              },
              "display_name": {
                "type": "string"
              },
              "type": {
                "type": "string",
                "enum": ["individual", "business"]
              },
              "language": {
                "type": "string",
                "nullable": true
              }
            }
          },
          "type": {
            "$ref": "#/components/schemas/SupportCaseType"
          },
          "priority": {
            "$ref": "#/components/schemas/SupportPriority"
          },
          "status": {
            "$ref": "#/components/schemas/SupportCaseStatus"
          },
          "queue": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportQueueRef"
              }
            ],
            "nullable": true
          },
          "assignee": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportPersonRef"
              }
            ],
            "nullable": true
          },
          "origin": {
            "$ref": "#/components/schemas/SupportOrigin"
          },
          "channel": {
            "$ref": "#/components/schemas/SupportChannel"
          },
          "language": {
            "type": "string"
          },
          "flags": {
            "$ref": "#/components/schemas/SupportCaseFlags"
          },
          "sla": {
            "$ref": "#/components/schemas/SupportCaseSla"
          },
          "statutory": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportCaseStatutory"
              }
            ],
            "nullable": true
          },
          "complaint_reference": {
            "type": "string",
            "nullable": true
          },
          "last_customer_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "last_agent_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "watching": {
            "type": "boolean",
            "description": "The viewer watches the case (ARCH-030 \u00a77.2)."
          },
          "unseen": {
            "type": "boolean",
            "description": "The viewer watches or has the case and it changed since the viewer last opened it (case detail or activity)."
          },
          "can": {
            "$ref": "#/components/schemas/SupportCaseCan"
          },
          "preview": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportCasePreview"
              }
            ],
            "nullable": true,
            "description": "Inbox rows only. Null for a locked or compliance-queue case, for a case with the silent compliance marker (every role but mlro and auditor) and for a case without words."
          },
          "ai": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportCaseAiOversight"
              }
            ],
            "description": "Rows of `ai_only=true` or `ai_handled=true` only."
          }
        }
      },
      "SupportCasePreview": {
        "type": "object",
        "required": ["author", "text", "at"],
        "properties": {
          "author": {
            "type": "string",
            "enum": ["customer", "ai", "agent"]
          },
          "text": {
            "type": "string",
            "maxLength": 600,
            "description": "At most 140 characters, white space collapsed, \"\u2026\" when cut."
          },
          "at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SupportAiOutcome": {
        "type": "string",
        "enum": ["resolved_by_ai", "with_ai", "handed_over"],
        "description": "What became of an AI chat: ended without a person, still with the AI, or handed to the team."
      },
      "SupportCaseAiOversight": {
        "type": "object",
        "required": [
          "answers",
          "fixed_text_answers",
          "helpful",
          "not_helpful",
          "rating",
          "outcome",
          "handoff_reason",
          "flagged",
          "first_question"
        ],
        "properties": {
          "answers": {
            "type": "integer",
            "description": "AI answers in the case."
          },
          "fixed_text_answers": {
            "type": "integer",
            "description": "AI answers that were an approved fixed text instead of a model answer."
          },
          "helpful": {
            "type": "integer",
            "description": "\"Did that help?\" answered yes."
          },
          "not_helpful": {
            "type": "integer",
            "description": "\"Did that help?\" answered no."
          },
          "rating": {
            "type": "integer",
            "minimum": 1,
            "maximum": 5,
            "nullable": true
          },
          "outcome": {
            "$ref": "#/components/schemas/SupportAiOutcome"
          },
          "handoff_reason": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportHandoffReason"
              }
            ],
            "nullable": true,
            "description": "When handed over; a restricted-topic reason only for `mlro` and `auditor`."
          },
          "flagged": {
            "type": "boolean",
            "description": "The customer said an answer did not help."
          },
          "first_question": {
            "type": "string",
            "nullable": true,
            "description": "The customer's first message (excerpt); null for a locked or compliance-queue case."
          }
        }
      },
      "SupportCaseList": {
        "type": "object",
        "required": ["cases", "next_cursor", "has_more"],
        "properties": {
          "cases": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportCaseSummary"
            }
          },
          "next_cursor": {
            "type": "string",
            "nullable": true
          },
          "has_more": {
            "type": "boolean"
          }
        }
      },
      "SupportCase": {
        "allOf": [
          {
            "$ref": "#/components/schemas/SupportCaseSummary"
          },
          {
            "type": "object",
            "required": ["conversation_id"],
            "properties": {
              "conversation_id": {
                "type": "string",
                "format": "uuid"
              },
              "handoff": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/SupportCaseHandoff"
                  }
                ],
                "nullable": true
              },
              "complaint": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/SupportCaseComplaint"
                  }
                ],
                "nullable": true
              },
              "reopen_until": {
                "type": "string",
                "format": "date-time",
                "nullable": true
              },
              "watchers": {
                "type": "array",
                "description": "ARCH-030 \u00a76.2, \u00a77.2: the watchers who may see the case.",
                "items": {
                  "$ref": "#/components/schemas/SupportWatcher"
                }
              },
              "case_links": {
                "type": "array",
                "description": "ARCH-030 \u00a76.2, \u00a77.7 (the contract's `links` list; `links` stays the 029a object): compliance case links only for mlro and auditor, a related case only when the viewer may see it.",
                "items": {
                  "$ref": "#/components/schemas/SupportCaseLink"
                }
              },
              "compliance_linked_transfers": {
                "type": "array",
                "description": "0.28.1, every staff role: the payments the silent compliance marker names (one marker per payment under a compliance hold, written by the support held check job within about a minute of the customer's message, ARCH-029a \u00a73.5a); empty without one.",
                "items": {
                  "type": "string"
                }
              },
              "links": {
                "type": "object",
                "properties": {
                  "transfer_id": {
                    "type": "string",
                    "nullable": true
                  },
                  "card_id": {
                    "type": "string",
                    "nullable": true
                  },
                  "account_id": {
                    "type": "string",
                    "nullable": true
                  },
                  "kyc_session_id": {
                    "type": "string",
                    "nullable": true
                  },
                  "compliance_case_id": {
                    "type": "string",
                    "nullable": true,
                    "description": "mlro and auditor only."
                  }
                }
              },
              "requests": {
                "type": "array",
                "description": "Tickets only, by seq; stored statuses with every attempt.",
                "items": {
                  "$ref": "#/components/schemas/SupportStaffRequest"
                }
              },
              "files": {
                "type": "array",
                "description": "Tickets only; filled by SF-tickets-files (empty until then).",
                "items": {
                  "type": "object",
                  "additionalProperties": true
                }
              },
              "csat": {
                "type": "object",
                "nullable": true,
                "required": ["rating", "score", "comment", "at"],
                "properties": {
                  "rating": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 5,
                    "description": "The customer's rating (0.32.0)."
                  },
                  "score": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 5,
                    "deprecated": true,
                    "description": "The same as `rating`; kept for older consoles."
                  },
                  "comment": {
                    "type": "string",
                    "nullable": true
                  },
                  "at": {
                    "type": "string",
                    "format": "date-time"
                  }
                }
              },
              "resolved_at": {
                "type": "string",
                "format": "date-time",
                "nullable": true
              },
              "closed_at": {
                "type": "string",
                "format": "date-time",
                "nullable": true
              }
            }
          }
        ]
      },
      "SupportTicketInfo": {
        "type": "object",
        "description": "The ticket part of a SupportCase (ARCH-030 \u00a76.2). `category` aml_rfi tickets reach only mlro and auditor.",
        "required": [
          "initiator",
          "category",
          "time_zone",
          "show_link",
          "customer_status",
          "requests_summary",
          "letters"
        ],
        "properties": {
          "initiator": {
            "type": "string",
            "enum": ["customer", "bank"]
          },
          "category": {
            "$ref": "#/components/schemas/SupportTicketCategory"
          },
          "topic": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportTicketTopic"
              }
            ],
            "nullable": true
          },
          "subject": {
            "type": "string",
            "nullable": true
          },
          "due_date": {
            "type": "string",
            "format": "date",
            "nullable": true,
            "description": "The nearest due date of an open required request, else the ticket's."
          },
          "time_zone": {
            "type": "string",
            "example": "Europe/Madrid"
          },
          "show_link": {
            "type": "boolean"
          },
          "link": {
            "type": "object",
            "nullable": true,
            "properties": {
              "kind": {
                "type": "string",
                "enum": ["transfer", "card", "account", "verification"]
              },
              "id": {
                "type": "string"
              }
            }
          },
          "customer_status": {
            "$ref": "#/components/schemas/SupportTicketStatus"
          },
          "requests_summary": {
            "type": "object",
            "properties": {
              "pending": {
                "type": "integer"
              },
              "submitted": {
                "type": "integer"
              },
              "rejected": {
                "type": "integer"
              },
              "accepted": {
                "type": "integer"
              },
              "cancelled": {
                "type": "integer"
              },
              "overdue": {
                "type": "integer"
              }
            }
          },
          "resolution": {
            "type": "object",
            "nullable": true,
            "properties": {
              "text": {
                "type": "string"
              },
              "code": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/SupportResolutionCode"
                  }
                ],
                "nullable": true
              },
              "at": {
                "type": "string",
                "format": "date-time"
              },
              "by": {
                "type": "string",
                "format": "uuid"
              }
            }
          },
          "close_reason": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportCloseReason"
              }
            ],
            "nullable": true
          },
          "retention_class": {
            "$ref": "#/components/schemas/SupportRetentionClass"
          },
          "template": {
            "type": "object",
            "nullable": true,
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "code": {
                "type": "string"
              },
              "version": {
                "type": "integer"
              }
            }
          },
          "letters": {
            "type": "array",
            "description": "The ticket's letters with the customer's first download.",
            "items": {
              "$ref": "#/components/schemas/SupportStaffLetterRef"
            }
          },
          "origin_case_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          }
        }
      },
      "SupportStaffRequest": {
        "type": "object",
        "required": [
          "id",
          "seq",
          "kind",
          "status",
          "required",
          "review_required",
          "attempt",
          "attempts"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "seq": {
            "type": "integer",
            "minimum": 1,
            "maximum": 20
          },
          "kind": {
            "$ref": "#/components/schemas/SupportRequestKind"
          },
          "title": {
            "type": "string",
            "maxLength": 120,
            "nullable": true
          },
          "prompt": {
            "type": "string",
            "maxLength": 2000,
            "nullable": true
          },
          "consequence": {
            "type": "string",
            "maxLength": 600,
            "nullable": true
          },
          "consequential": {
            "type": "boolean"
          },
          "letter_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "required": {
            "type": "boolean"
          },
          "review_required": {
            "type": "boolean"
          },
          "status": {
            "$ref": "#/components/schemas/SupportRequestStatus"
          },
          "due_date": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "time_zone": {
            "type": "string"
          },
          "overdue": {
            "type": "boolean"
          },
          "document_types": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportDocumentType"
            }
          },
          "min_files": {
            "type": "integer",
            "nullable": true
          },
          "max_files": {
            "type": "integer",
            "nullable": true
          },
          "attempt": {
            "type": "integer"
          },
          "submitted_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "template": {
            "type": "object",
            "nullable": true,
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "version": {
                "type": "integer"
              }
            }
          },
          "attempts": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "attempt": {
                  "type": "integer"
                },
                "client_submission_id": {
                  "type": "string",
                  "format": "uuid"
                },
                "submitted_at": {
                  "type": "string",
                  "format": "date-time"
                },
                "answer": {
                  "type": "string",
                  "nullable": true
                },
                "confirm": {
                  "type": "boolean",
                  "nullable": true
                },
                "decision": {
                  "type": "string",
                  "enum": ["accepted", "rejected"],
                  "nullable": true
                },
                "decided_by_system": {
                  "type": "boolean"
                },
                "review": {
                  "type": "object",
                  "nullable": true,
                  "properties": {
                    "reason": {
                      "$ref": "#/components/schemas/SupportReviewReason"
                    },
                    "note": {
                      "type": "string",
                      "nullable": true
                    }
                  }
                },
                "reviewed_by": {
                  "type": "string",
                  "format": "uuid",
                  "nullable": true
                },
                "reviewed_at": {
                  "type": "string",
                  "format": "date-time",
                  "nullable": true
                },
                "files": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SupportTicketFile"
                  }
                }
              }
            }
          },
          "reviewed_by": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "reviewed_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "cancelled_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "cancelled_by": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          }
        }
      },
      "SupportUpload": {
        "type": "object",
        "description": "An upload (ARCH-030 \u00a75.1). `purpose` on staff uploads only.",
        "required": [
          "upload_id",
          "content_type",
          "size_bytes",
          "sha256",
          "scan",
          "attached",
          "created_at"
        ],
        "properties": {
          "upload_id": {
            "type": "string",
            "format": "uuid"
          },
          "file_name": {
            "type": "string",
            "maxLength": 120,
            "nullable": true
          },
          "content_type": {
            "type": "string",
            "enum": ["application/pdf", "image/jpeg", "image/png"]
          },
          "size_bytes": {
            "type": "integer",
            "minimum": 1,
            "maximum": 10485760
          },
          "sha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "scan": {
            "type": "string",
            "description": "Customer: `not_scanned` (shown as uploaded), `pending`, `clean`, `rejected`. Staff: the stored `scan_status` (`not_scanned`, `pending`, `clean`, `infected`, `failed`)."
          },
          "attached": {
            "type": "boolean"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "purpose": {
            "type": "string",
            "enum": ["ticket", "withdrawal_evidence", "counsel_approval"]
          }
        }
      },
      "SupportTicketFile": {
        "type": "object",
        "description": "A file of a ticket (ARCH-030 \u00a75.1). Staff answers add `sha256`,\n`purpose`, `message_id`, `request_id`, `attempt` and `erased`, and\n`scan` is the stored value.\n",
        "required": [
          "id",
          "content_type",
          "size_bytes",
          "scan",
          "uploaded_by",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "file_name": {
            "type": "string",
            "maxLength": 120,
            "nullable": true
          },
          "content_type": {
            "type": "string",
            "enum": ["application/pdf", "image/jpeg", "image/png"]
          },
          "size_bytes": {
            "type": "integer"
          },
          "document_type": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportDocumentType"
              }
            ],
            "nullable": true
          },
          "scan": {
            "type": "string"
          },
          "uploaded_by": {
            "type": "string",
            "enum": ["customer", "bank"]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "sha256": {
            "type": "string"
          },
          "purpose": {
            "type": "string"
          },
          "message_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "request_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "attempt": {
            "type": "integer",
            "nullable": true
          },
          "erased": {
            "type": "boolean"
          }
        }
      },
      "SupportRequestInput": {
        "type": "object",
        "description": "A free request, or `{ \"template_request\": code, \"slots\": {} }` from an\napproved template of the ticket's category (aml_rfi only this form).\n",
        "properties": {
          "kind": {
            "$ref": "#/components/schemas/SupportRequestKind"
          },
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "prompt": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2000
          },
          "document_types": {
            "type": "array",
            "minItems": 1,
            "maxItems": 5,
            "items": {
              "$ref": "#/components/schemas/SupportDocumentType"
            }
          },
          "min_files": {
            "type": "integer",
            "minimum": 1,
            "maximum": 10,
            "default": 1
          },
          "max_files": {
            "type": "integer",
            "minimum": 1,
            "maximum": 10,
            "default": 5
          },
          "required": {
            "type": "boolean",
            "default": true
          },
          "review_required": {
            "type": "boolean",
            "description": "Default: false for confirm, true for answer and documents; documents cannot set false."
          },
          "due_date": {
            "type": "string",
            "format": "date"
          },
          "template_request": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]{2,47}$"
          },
          "slots": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "SupportCreateTicketRequest": {
        "type": "object",
        "description": "POST /support/cases with kind ticket (ARCH-030 \u00a76.1).",
        "required": ["kind", "customer_id", "category"],
        "properties": {
          "kind": {
            "type": "string",
            "enum": ["ticket"]
          },
          "customer_id": {
            "type": "string",
            "format": "uuid"
          },
          "category": {
            "type": "string",
            "enum": ["general", "kyc", "risk", "aml_rfi"]
          },
          "template_id": {
            "type": "string",
            "format": "uuid",
            "description": "Required for aml_rfi."
          },
          "slots": {
            "type": "object",
            "additionalProperties": true
          },
          "subject": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120,
            "description": "Without a template required; with one overridable for general, kyc, risk."
          },
          "message": {
            "type": "string",
            "minLength": 1,
            "maxLength": 4000
          },
          "requests": {
            "type": "array",
            "maxItems": 10,
            "items": {
              "$ref": "#/components/schemas/SupportRequestInput"
            }
          },
          "due_date": {
            "type": "string",
            "format": "date",
            "description": "Tomorrow to 90 days ahead (tenant zone)."
          },
          "links": {
            "type": "object",
            "properties": {
              "transfer_id": {
                "type": "string",
                "nullable": true
              },
              "card_id": {
                "type": "string",
                "nullable": true
              },
              "account_id": {
                "type": "string",
                "nullable": true
              },
              "kyc_session_id": {
                "type": "string",
                "nullable": true
              },
              "compliance_case_id": {
                "type": "string",
                "nullable": true,
                "description": "mlro only; required for aml_rfi."
              },
              "origin_case_id": {
                "type": "string",
                "nullable": true
              }
            }
          },
          "show_link": {
            "type": "boolean",
            "default": true
          },
          "queue_code": {
            "type": "string",
            "nullable": true
          },
          "assignee_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "language": {
            "$ref": "#/components/schemas/SupportLocale"
          }
        }
      },
      "SupportAddRequestsRequest": {
        "type": "object",
        "required": ["requests"],
        "properties": {
          "requests": {
            "type": "array",
            "minItems": 1,
            "maxItems": 10,
            "items": {
              "$ref": "#/components/schemas/SupportRequestInput"
            }
          },
          "message": {
            "type": "object",
            "required": ["client_message_id", "body"],
            "properties": {
              "client_message_id": {
                "type": "string",
                "format": "uuid"
              },
              "body": {
                "type": "string",
                "maxLength": 4000
              }
            }
          }
        }
      },
      "SupportThreadFeedbackRequest": {
        "type": "object",
        "required": ["message_id", "helped", "client_request_id"],
        "properties": {
          "message_id": {
            "type": "string",
            "format": "uuid",
            "description": "An AI answer of this thread."
          },
          "helped": {
            "type": "boolean",
            "description": "true: \"Yes, thanks\"; false: not helped (recorded only)."
          },
          "client_request_id": {
            "type": "string",
            "format": "uuid",
            "description": "Replay key; a replay answers 200 with the thread."
          }
        }
      },
      "SupportConversation": {
        "type": "object",
        "description": "One row of the customer's conversation list (DEC-0033 decision 30), one per thread (0.33.0). Only what the customer sees.",
        "required": [
          "kind",
          "id",
          "thread_id",
          "title",
          "topic",
          "initiator",
          "status",
          "active",
          "open",
          "can_close",
          "current",
          "last_author",
          "unread",
          "open_requests",
          "due_date",
          "overdue",
          "started_at",
          "last_activity_at"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "enum": ["chat", "request", "complaint"],
            "description": "`chat`: a chat thread (`/chats/{thread_id}`); `complaint` (0.33.0):\na chat registered as a complaint, same routes, closing it\nwithdraws the complaint; `request`: a ticket (`/tickets/{id}`),\nalso when it is a complaint. Clients show an unknown value as\n`chat`.\n"
          },
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The chat case, or the ticket."
          },
          "thread_id": {
            "type": "string",
            "format": "uuid",
            "description": "0.33.0. The thread (the case id, the same as `id`)."
          },
          "title": {
            "type": "string",
            "nullable": true,
            "description": "A request's subject, or the customer's own first words of a chat (one line, at most 80 characters)."
          },
          "topic": {
            "type": "string",
            "nullable": true,
            "description": "The topic of a request the customer opened."
          },
          "initiator": {
            "type": "string",
            "enum": ["customer", "bank"]
          },
          "status": {
            "type": "string",
            "enum": ["answered", "waiting_for_us", "waiting_for_you", "done"]
          },
          "active": {
            "type": "boolean",
            "description": "Not done."
          },
          "open": {
            "type": "boolean",
            "description": "0.33.0. The thread accepts a reply: a chat whose case is not\nclosed (a resolved one only inside its reopen window; a\ntipping-off-locked case the bank closed reads open, as\neverywhere), which the customer can also end; a request that is\nopen, or resolved inside its reopen window (its `can.reply`).\nClients list open threads first.\n"
          },
          "can_close": {
            "type": "boolean",
            "description": "0.33.0. The customer may end it now: a chat or complaint\n(`POST /chats/{thread_id}/close`, a complaint with\n`confirm: true`); a request it may withdraw\n(`POST /tickets/{id}/withdraw`: its own open request, or an\nopen complaint). A request the bank opened cannot be withdrawn.\n"
          },
          "current": {
            "type": "boolean",
            "description": "The case `GET /thread` shows (the legacy single thread; mobile)."
          },
          "last_author": {
            "type": "string",
            "enum": ["you", "assistant", "team"],
            "nullable": true,
            "description": "The newest message the customer sees, system lines aside. Never the AI text."
          },
          "unread": {
            "type": "integer",
            "minimum": 0
          },
          "open_requests": {
            "type": "integer",
            "minimum": 0,
            "description": "Required requests the bank waits for (requests only)."
          },
          "due_date": {
            "type": "string",
            "format": "date",
            "nullable": true,
            "description": "The bank's calendar day."
          },
          "overdue": {
            "type": "boolean"
          },
          "started_at": {
            "type": "string",
            "format": "date-time"
          },
          "last_activity_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SupportConversationPage": {
        "type": "object",
        "required": [
          "conversations",
          "next_cursor",
          "has_more",
          "unread_total",
          "new_chat"
        ],
        "properties": {
          "conversations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportConversation"
            }
          },
          "next_cursor": {
            "type": "string",
            "nullable": true
          },
          "has_more": {
            "type": "boolean"
          },
          "unread_total": {
            "type": "integer",
            "minimum": 0,
            "description": "0.33.0. Every unread line of every thread of the customer, open\nand closed, chats and requests (not only this page), counted as\nthe rows count them: a chat's assistant, agent and system lines\nafter its read marker that the customer is shown (the masked\nlines of a tipping-off-locked case never count), a request's\nagent and system lines after its read marker. Only the threads\nof the features that are on. The portal's badge (poll with\n`If-None-Match`).\n"
          },
          "new_chat": {
            "type": "object",
            "required": ["assistant"],
            "description": "0.33.0. What a new chat (`POST /chats`) would get now.",
            "properties": {
              "assistant": {
                "type": "boolean",
                "description": "The assistant would answer a new chat of this customer now:\n`support_chat` on and the gates of a first message on\n`POST /chats` open (`support_ai`, the AI policy's kill\nswitches and monthly token cap, the tenant's cap, the\ncircuit breaker, and the policy's turns per customer and\nhour, read from the last hour's turns without counting\none). Clients show the AI disclosure before the first\nmessage when true. A hint for the screen: the message itself\nstill takes the gates as they are when it is sent.\n"
              }
            }
          }
        }
      },
      "SupportChat": {
        "type": "object",
        "description": "One chat thread (0.33.0, DEC-0033 amendment 2026-10-05): a chat case\nof the customer with that case's messages only. Same body for\n`GET /chats/{threadId}`, `POST /chats` and the thread writes that\nanswer a thread.\n",
        "required": [
          "id",
          "thread_id",
          "kind",
          "title",
          "status",
          "customer_status",
          "open",
          "waiting",
          "expected_reply_by",
          "expected_reply",
          "ai_enabled",
          "disclosure_required",
          "disclosure_key",
          "language",
          "time_zone",
          "case_reference",
          "assignee",
          "unread",
          "reopen_until",
          "complaint",
          "can",
          "resolution_prompt",
          "csat",
          "messages",
          "next_cursor",
          "has_more",
          "latest_cursor",
          "started_at",
          "closed_at",
          "updated_at",
          "support_availability"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The thread (the case)."
          },
          "thread_id": {
            "type": "string",
            "format": "uuid",
            "description": "The same as `id`."
          },
          "kind": {
            "type": "string",
            "enum": ["chat", "complaint"],
            "description": "`complaint`: registered as a complaint; ending it withdraws the complaint."
          },
          "title": {
            "type": "string",
            "nullable": true,
            "description": "The customer's own first words in the thread (one line, at most 80 characters); null before the customer wrote."
          },
          "status": {
            "type": "string",
            "enum": ["answered", "waiting_for_us", "waiting_for_you", "done"],
            "description": "The plain state, as in `GET /conversations`."
          },
          "customer_status": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportCustomerStatus"
              }
            ],
            "description": "The thread's status (ARCH-029a \u00a73.2), with the tipping-off rules."
          },
          "open": {
            "type": "boolean",
            "description": "The thread accepts a reply and can be ended (as `GET /conversations`). Closed threads are read-only."
          },
          "waiting": {
            "type": "string",
            "enum": ["assistant", "person", "you", "none"],
            "description": "Who has it and what happens next (D6): `assistant` the AI is\nanswering; `person` waiting for a person (see\n`expected_reply_by`); `you` the bank waits for the customer;\n`none` nothing pending (the assistant answered, a person\nanswered, or the thread is done).\n"
          },
          "expected_reply_by": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "With `waiting` `person`: the next opening of the bank's hours\n(the general queue's hours, never the case's queue) when it is\nclosed now; null when it is open now, unknown or not shown\n(`show_expected_reply` off): \"as soon as we can\".\n"
          },
          "expected_reply": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportExpectedReply"
              }
            ],
            "nullable": true,
            "description": "As `GET /thread` (while `customer_status` is `waiting`)."
          },
          "ai_enabled": {
            "type": "boolean",
            "description": "The AI answers the next message of this thread (ARCH-029a \u00a72.3); false on a closed thread."
          },
          "disclosure_required": {
            "type": "boolean",
            "description": "ai_enabled or any AI message in the thread; clients show the assistant.disclosure line at the top and the \"AI answer\" label on every AI message."
          },
          "disclosure_key": {
            "type": "string",
            "enum": ["assistant.disclosure"]
          },
          "language": {
            "type": "string",
            "nullable": true,
            "example": "es"
          },
          "time_zone": {
            "type": "string",
            "example": "Europe/Madrid"
          },
          "case_reference": {
            "type": "string",
            "example": "SR-2026-000412"
          },
          "assignee": {
            "type": "object",
            "nullable": true,
            "required": ["display_name"],
            "properties": {
              "display_name": {
                "type": "string"
              }
            }
          },
          "unread": {
            "type": "integer",
            "minimum": 0
          },
          "reopen_until": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "complaint": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportComplaintAck"
              }
            ],
            "nullable": true
          },
          "can": {
            "type": "object",
            "description": "What the customer may do on this thread now. Clients offer exactly these.",
            "required": [
              "reply",
              "close",
              "close_withdraws_complaint",
              "talk_to_person",
              "complaint",
              "rate",
              "feedback"
            ],
            "properties": {
              "reply": {
                "type": "boolean",
                "description": "POST /chats/{threadId}/messages."
              },
              "close": {
                "type": "boolean",
                "description": "POST /chats/{threadId}/close (any open status)."
              },
              "close_withdraws_complaint": {
                "type": "boolean",
                "description": "Ending the thread withdraws its complaint (`confirm` true; show the consequence first)."
              },
              "talk_to_person": {
                "type": "boolean",
                "description": "POST /chats/{threadId}/handoff `customer_request` hands the thread to a person (the assistant has it)."
              },
              "complaint": {
                "type": "boolean",
                "description": "POST /chats/{threadId}/handoff `complaint` (open and not a complaint yet)."
              },
              "rate": {
                "type": "boolean",
                "description": "POST /chats/{threadId}/csat."
              },
              "feedback": {
                "type": "boolean",
                "description": "POST /chats/{threadId}/feedback (`resolution_prompt` is set)."
              }
            }
          },
          "resolution_prompt": {
            "type": "object",
            "nullable": true,
            "required": ["message_id"],
            "properties": {
              "message_id": {
                "type": "string",
                "format": "uuid"
              }
            }
          },
          "csat": {
            "type": "object",
            "required": ["asked", "score"],
            "properties": {
              "asked": {
                "type": "boolean"
              },
              "score": {
                "type": "integer",
                "minimum": 1,
                "maximum": 5,
                "nullable": true
              }
            }
          },
          "messages": {
            "type": "array",
            "description": "Newest page of this thread's messages, oldest first.",
            "items": {
              "$ref": "#/components/schemas/SupportMessage"
            }
          },
          "next_cursor": {
            "type": "string",
            "nullable": true
          },
          "has_more": {
            "type": "boolean"
          },
          "latest_cursor": {
            "type": "string",
            "nullable": true
          },
          "started_at": {
            "type": "string",
            "format": "date-time"
          },
          "closed_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the customer sees it closed; null while open."
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "support_availability": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportAvailability"
              }
            ],
            "nullable": true
          }
        }
      },
      "SupportChatCloseRequest": {
        "type": "object",
        "required": ["client_request_id", "reason"],
        "properties": {
          "client_request_id": {
            "type": "string",
            "format": "uuid",
            "description": "Replay key; a replay answers 200 with the thread."
          },
          "reason": {
            "type": "string",
            "enum": ["resolved", "no_longer_needed"],
            "description": "`resolved`: \"It's sorted\"; `no_longer_needed`."
          },
          "confirm": {
            "type": "boolean",
            "nullable": true,
            "description": "Required (true) when the thread is a complaint (`can.close_withdraws_complaint`); ignored otherwise."
          }
        }
      },
      "SupportThreadCloseRequest": {
        "type": "object",
        "required": ["client_request_id"],
        "properties": {
          "client_request_id": {
            "type": "string",
            "format": "uuid",
            "description": "Replay key; a replay answers 200 with the thread."
          }
        }
      },
      "SupportCloseCaseRequest": {
        "type": "object",
        "required": ["reason"],
        "properties": {
          "reason": {
            "type": "string",
            "minLength": 1,
            "maxLength": 1000,
            "description": "Customer-visible (the resolution), except on a tipping-off-locked chat case."
          },
          "resolution_code": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportResolutionCode"
              }
            ],
            "description": "Tickets only."
          },
          "cancel_open_requests": {
            "type": "boolean",
            "default": false,
            "description": "Tickets only - cancel pending and rejected requests with the close."
          }
        }
      },
      "SupportReopenCaseRequest": {
        "type": "object",
        "required": ["reason"],
        "properties": {
          "reason": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500,
            "description": "Internal."
          }
        }
      },
      "SupportCancelRequest": {
        "type": "object",
        "required": ["reason"],
        "properties": {
          "reason": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500,
            "description": "Internal."
          },
          "customer_note": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500,
            "description": "Customer-visible."
          }
        }
      },
      "SupportReviewRequest": {
        "type": "object",
        "required": ["decision"],
        "properties": {
          "decision": {
            "type": "string",
            "enum": ["accept", "reject"]
          },
          "reason": {
            "$ref": "#/components/schemas/SupportReviewReason"
          },
          "note": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500,
            "description": "Customer-visible; required with reason other."
          },
          "file_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          }
        }
      },
      "SupportCustomerTicketRef": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "reference": {
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/SupportCaseStatus"
          },
          "customer_status": {
            "$ref": "#/components/schemas/SupportTicketStatus"
          },
          "initiator": {
            "type": "string",
            "enum": ["customer", "bank"]
          },
          "category": {
            "$ref": "#/components/schemas/SupportTicketCategory"
          },
          "subject": {
            "type": "string",
            "nullable": true
          },
          "due_date": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "time_zone": {
            "type": "string"
          },
          "open_requests": {
            "type": "integer"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SupportTemplateTexts": {
        "type": "object",
        "required": ["subject", "message", "requests"],
        "properties": {
          "subject": {
            "type": "string",
            "maxLength": 120
          },
          "message": {
            "type": "string",
            "maxLength": 4000
          },
          "requests": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "title": {
                  "type": "string",
                  "maxLength": 120
                },
                "prompt": {
                  "type": "string",
                  "maxLength": 2000
                }
              }
            }
          },
          "consequence": {
            "type": "string",
            "maxLength": 600,
            "description": "Makes the template consequential (letters)."
          },
          "resolution": {
            "type": "string",
            "maxLength": 1000
          }
        }
      },
      "SupportTemplateRequestDef": {
        "type": "object",
        "required": ["kind"],
        "properties": {
          "kind": {
            "$ref": "#/components/schemas/SupportRequestKind"
          },
          "document_types": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportDocumentType"
            }
          },
          "min_files": {
            "type": "integer",
            "nullable": true
          },
          "max_files": {
            "type": "integer",
            "nullable": true
          },
          "required": {
            "type": "boolean"
          },
          "review_required": {
            "type": "boolean"
          }
        }
      },
      "SupportTemplateSlot": {
        "type": "object",
        "required": ["name", "type"],
        "properties": {
          "name": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]{0,31}$"
          },
          "type": {
            "$ref": "#/components/schemas/SupportSlotType"
          },
          "max_length": {
            "type": "integer",
            "minimum": 1,
            "maximum": 200
          }
        }
      },
      "SupportRequestTemplateInput": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]{2,47}$"
          },
          "category": {
            "type": "string",
            "enum": ["general", "kyc", "risk", "aml_rfi"]
          },
          "texts": {
            "type": "object",
            "additionalProperties": {
              "$ref": "#/components/schemas/SupportTemplateTexts"
            }
          },
          "requests": {
            "type": "array",
            "maxItems": 10,
            "items": {
              "$ref": "#/components/schemas/SupportTemplateRequestDef"
            }
          },
          "slots": {
            "type": "array",
            "maxItems": 10,
            "items": {
              "$ref": "#/components/schemas/SupportTemplateSlot"
            }
          },
          "default_due_days": {
            "type": "integer",
            "minimum": 1,
            "maximum": 90,
            "nullable": true
          },
          "show_link": {
            "type": "boolean"
          },
          "retention_class": {
            "type": "string",
            "enum": ["support", "cdd"]
          }
        }
      },
      "SupportRequestTemplate": {
        "type": "object",
        "required": [
          "id",
          "code",
          "category",
          "version",
          "status",
          "texts",
          "requests",
          "slots",
          "approvals"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "code": {
            "type": "string"
          },
          "category": {
            "$ref": "#/components/schemas/SupportTicketCategory"
          },
          "version": {
            "type": "integer",
            "minimum": 1
          },
          "status": {
            "$ref": "#/components/schemas/SupportTemplateStatus"
          },
          "texts": {
            "type": "object",
            "additionalProperties": {
              "$ref": "#/components/schemas/SupportTemplateTexts"
            }
          },
          "requests": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportTemplateRequestDef"
            }
          },
          "slots": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportTemplateSlot"
            }
          },
          "default_due_days": {
            "type": "integer",
            "nullable": true
          },
          "show_link": {
            "type": "boolean"
          },
          "retention_class": {
            "type": "string",
            "enum": ["support", "cdd"]
          },
          "consequential": {
            "type": "boolean"
          },
          "seeded": {
            "type": "boolean"
          },
          "approvals": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "role": {
                  "type": "string",
                  "enum": [
                    "editor",
                    "mlro",
                    "bank_admin",
                    "risk_officer",
                    "legal_counsel"
                  ]
                },
                "user_id": {
                  "type": "string",
                  "format": "uuid",
                  "nullable": true
                },
                "name": {
                  "type": "string"
                },
                "at": {
                  "type": "string",
                  "format": "date-time"
                },
                "approved_on": {
                  "type": "string",
                  "format": "date",
                  "nullable": true
                },
                "evidence_file_id": {
                  "type": "string",
                  "format": "uuid",
                  "nullable": true
                }
              }
            }
          },
          "created_by": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "last_editor_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "proposed_by": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "proposed_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "approved_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "archived_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SupportTemplateApproveRequest": {
        "type": "object",
        "properties": {
          "counsel_approval": {
            "type": "object",
            "description": "aml_rfi only and required there.",
            "required": ["name", "approved_on", "evidence_file_id"],
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 120
              },
              "approved_on": {
                "type": "string",
                "format": "date"
              },
              "evidence_file_id": {
                "type": "string",
                "format": "uuid",
                "description": "A staff upload (purpose counsel_approval) of counsel's written sign-off."
              }
            }
          }
        }
      },
      "SupportTopicList": {
        "type": "object",
        "required": ["topics"],
        "properties": {
          "topics": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "code": {
                  "$ref": "#/components/schemas/SupportTicketTopic"
                },
                "active": {
                  "type": "boolean"
                },
                "sort": {
                  "type": "integer"
                },
                "attachments": {
                  "type": "boolean"
                }
              }
            }
          }
        }
      },
      "SupportCustomerRequestStatus": {
        "type": "string",
        "description": "A request as the customer sees it (ARCH-030 \u00a72); clients show an unknown value as `open`.",
        "enum": ["open", "submitted", "accepted", "not_accepted", "cancelled"]
      },
      "SupportCustomerScanStatus": {
        "type": "string",
        "description": "`not_scanned` (shown as uploaded) while no scanner exists (ARCH-030 \u00a78.3).",
        "enum": ["not_scanned", "pending", "clean", "rejected"]
      },
      "SupportTicketInitiator": {
        "type": "string",
        "description": "Who opened the ticket; clients show an unknown value as `bank`.",
        "enum": ["customer", "bank"]
      },
      "SupportTicketSummary": {
        "type": "object",
        "description": "One ticket in the customer's list (ARCH-030 \u00a75.1).",
        "required": [
          "id",
          "reference",
          "initiator",
          "topic",
          "subject",
          "status",
          "due_date",
          "overdue",
          "time_zone",
          "open_requests",
          "unread",
          "complaint_reference",
          "has_letters",
          "resolution_preview",
          "last_activity_at",
          "created_at",
          "resolved_at",
          "closed_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The case id."
          },
          "reference": {
            "type": "string",
            "example": "SR-2026-000123"
          },
          "initiator": {
            "$ref": "#/components/schemas/SupportTicketInitiator"
          },
          "topic": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportTicketTopic"
              }
            ],
            "nullable": true,
            "description": "Tickets the customer opened only."
          },
          "subject": {
            "type": "string",
            "nullable": true,
            "description": "The bank's subject, or the customer's (null: clients show the topic label)."
          },
          "status": {
            "$ref": "#/components/schemas/SupportTicketStatus"
          },
          "due_date": {
            "type": "string",
            "format": "date",
            "nullable": true,
            "description": "Nearest due date of an open required request, in `time_zone`."
          },
          "overdue": {
            "type": "boolean",
            "description": "`due_date` has passed in `time_zone`."
          },
          "time_zone": {
            "type": "string",
            "example": "Europe/Madrid"
          },
          "open_requests": {
            "type": "integer",
            "description": "Required requests open or not accepted."
          },
          "unread": {
            "type": "integer",
            "description": "Agent and system messages after the read marker."
          },
          "complaint_reference": {
            "type": "string",
            "nullable": true,
            "example": "RC-2026-000017"
          },
          "has_letters": {
            "type": "boolean",
            "description": "A letter belongs to this ticket (ARCH-030 \u00a79)."
          },
          "resolution_preview": {
            "type": "string",
            "nullable": true,
            "description": "First 140 characters of the resolution text (past tickets only)."
          },
          "last_activity_at": {
            "type": "string",
            "format": "date-time"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "resolved_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "closed_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "SupportTicketList": {
        "type": "object",
        "required": ["tickets", "next_cursor", "has_more"],
        "properties": {
          "tickets": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportTicketSummary"
            }
          },
          "next_cursor": {
            "type": "string",
            "nullable": true,
            "description": "`k1.` cursor of the next page."
          },
          "has_more": {
            "type": "boolean"
          },
          "support_availability": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportAvailability"
              }
            ],
            "nullable": true
          }
        }
      },
      "SupportTicketLink": {
        "type": "object",
        "description": "The customer's own record the ticket is about (only when the bank shows it).",
        "required": ["kind", "id"],
        "properties": {
          "kind": {
            "type": "string",
            "enum": ["transfer", "card", "account", "verification"]
          },
          "id": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "SupportTicketCan": {
        "type": "object",
        "required": ["reply", "withdraw", "withdraw_complaint"],
        "properties": {
          "reply": {
            "type": "boolean",
            "description": "Open, or resolved before `reopen_until`."
          },
          "withdraw": {
            "type": "boolean",
            "description": "A ticket the customer opened, not a complaint, still open (not resolved, not closed)."
          },
          "withdraw_complaint": {
            "type": "boolean",
            "description": "The complaint withdrawal (ARCH-030 \u00a74.4) - a complaint without a final reply whose ticket is not closed."
          }
        }
      },
      "SupportTicketComplaint": {
        "description": "SupportComplaintAck; on a ticket `withdrawn_at` is always present.",
        "allOf": [
          {
            "$ref": "#/components/schemas/SupportComplaintAck"
          },
          {
            "type": "object",
            "required": ["withdrawn_at"],
            "properties": {
              "withdrawn_at": {
                "type": "string",
                "format": "date-time",
                "nullable": true
              }
            }
          }
        ]
      },
      "CustomerLetter": {
        "type": "object",
        "required": [
          "id",
          "reference",
          "kind",
          "language",
          "issued_at",
          "ticket_reference",
          "superseded",
          "opened"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "reference": {
            "type": "string",
            "example": "LT-2026-000031"
          },
          "kind": {
            "type": "string",
            "enum": [
              "request_notice",
              "request_notice_update",
              "complaint_withdrawal_confirmation"
            ],
            "description": "Unknown values are shown as `request_notice`."
          },
          "language": {
            "type": "string",
            "enum": ["en", "es", "de", "pt", "ar"]
          },
          "issued_at": {
            "type": "string",
            "format": "date-time"
          },
          "ticket_reference": {
            "type": "string",
            "nullable": true,
            "example": "SR-2026-000044"
          },
          "superseded": {
            "type": "boolean"
          },
          "opened": {
            "type": "boolean"
          }
        }
      },
      "CustomerLetterList": {
        "type": "object",
        "required": ["letters", "next_cursor", "has_more"],
        "properties": {
          "letters": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CustomerLetter"
            }
          },
          "next_cursor": {
            "type": "string",
            "nullable": true
          },
          "has_more": {
            "type": "boolean"
          }
        }
      },
      "SupportStaffLetterRef": {
        "type": "object",
        "required": ["id", "reference", "kind", "issued_at", "first_opened_at"],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "reference": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "request_notice",
              "request_notice_update",
              "complaint_withdrawal_confirmation"
            ]
          },
          "issued_at": {
            "type": "string",
            "format": "date-time"
          },
          "first_opened_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "SupportTicketLetterRef": {
        "type": "object",
        "required": ["id", "reference", "kind", "issued_at"],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "reference": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "request_notice",
              "request_notice_update",
              "complaint_withdrawal_confirmation"
            ]
          },
          "issued_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SupportTicketRequest": {
        "type": "object",
        "description": "A request of the bank as the customer sees it (ARCH-030 \u00a75.1).",
        "required": [
          "id",
          "seq",
          "kind",
          "title",
          "prompt",
          "consequence",
          "letter_id",
          "required",
          "status",
          "due_date",
          "document_types",
          "min_files",
          "max_files",
          "attempt",
          "submitted_at",
          "answer",
          "confirm",
          "review",
          "files"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "seq": {
            "type": "integer"
          },
          "kind": {
            "$ref": "#/components/schemas/SupportRequestKind"
          },
          "title": {
            "type": "string",
            "example": "Proof of address"
          },
          "prompt": {
            "type": "string"
          },
          "consequence": {
            "type": "string",
            "nullable": true,
            "description": "Consequential requests only; the same text as the letter."
          },
          "letter_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "required": {
            "type": "boolean"
          },
          "status": {
            "$ref": "#/components/schemas/SupportCustomerRequestStatus"
          },
          "due_date": {
            "type": "string",
            "format": "date",
            "nullable": true,
            "description": "In the ticket's `time_zone`."
          },
          "document_types": {
            "type": "array",
            "description": "`documents` only (1 to 5); empty otherwise.",
            "items": {
              "$ref": "#/components/schemas/SupportDocumentType"
            }
          },
          "min_files": {
            "type": "integer",
            "nullable": true
          },
          "max_files": {
            "type": "integer",
            "nullable": true
          },
          "attempt": {
            "type": "integer",
            "description": "Submissions so far."
          },
          "submitted_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "answer": {
            "type": "string",
            "nullable": true,
            "description": "The latest answer (or the comment of a documents submission)."
          },
          "confirm": {
            "type": "boolean",
            "nullable": true,
            "description": "`confirm` requests: the latest answer."
          },
          "review": {
            "type": "object",
            "nullable": true,
            "description": "Only with `not_accepted`.",
            "required": ["reason", "note"],
            "properties": {
              "reason": {
                "$ref": "#/components/schemas/SupportReviewReason"
              },
              "note": {
                "type": "string",
                "nullable": true
              }
            }
          },
          "files": {
            "type": "array",
            "description": "The latest attempt's files.",
            "items": {
              "$ref": "#/components/schemas/SupportTicketFile"
            }
          }
        }
      },
      "SupportTicketMessage": {
        "description": "SupportMessage plus `attachments`. Ticket system message `params`:\nticket_opened `{initiator}`; request_added, request_submitted,\nrequest_accepted, request_cancelled `{request_id, title}`;\nrequest_not_accepted `{request_id, title, reason}`;\nrequest_due_changed `{request_id, title, due_date, time_zone}`;\nticket_cancelled, ticket_withdrawn `{}`; resolution (agent, with\nbody) `{reference}`. Never AI.\n",
        "allOf": [
          {
            "$ref": "#/components/schemas/SupportMessage"
          },
          {
            "type": "object",
            "required": ["attachments"],
            "properties": {
              "attachments": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/SupportTicketFile"
                }
              }
            }
          }
        ]
      },
      "SupportTicketMessagePage": {
        "type": "object",
        "required": ["messages", "next_cursor", "has_more", "latest_cursor"],
        "properties": {
          "messages": {
            "type": "array",
            "description": "Oldest first.",
            "items": {
              "$ref": "#/components/schemas/SupportTicketMessage"
            }
          },
          "next_cursor": {
            "type": "string",
            "nullable": true
          },
          "has_more": {
            "type": "boolean"
          },
          "latest_cursor": {
            "type": "string",
            "nullable": true
          },
          "has_more_newer": {
            "type": "boolean"
          }
        }
      },
      "SupportTicket": {
        "description": "One ticket with its requests and newest messages (ARCH-030 \u00a75.1).",
        "allOf": [
          {
            "$ref": "#/components/schemas/SupportTicketSummary"
          },
          {
            "type": "object",
            "required": [
              "assignee",
              "link",
              "resolution",
              "reopen_until",
              "complaint",
              "letters",
              "can",
              "disclosure_required",
              "requests",
              "messages",
              "next_cursor",
              "has_more",
              "latest_cursor",
              "updated_at"
            ],
            "properties": {
              "assignee": {
                "type": "object",
                "nullable": true,
                "description": "The person, never a team.",
                "required": ["display_name"],
                "properties": {
                  "display_name": {
                    "type": "string"
                  }
                }
              },
              "link": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/SupportTicketLink"
                  }
                ],
                "nullable": true
              },
              "resolution": {
                "type": "object",
                "nullable": true,
                "description": "Null for a complaint (its final reply is in the messages).",
                "required": ["text", "at"],
                "properties": {
                  "text": {
                    "type": "string"
                  },
                  "at": {
                    "type": "string",
                    "format": "date-time",
                    "nullable": true
                  }
                }
              },
              "reopen_until": {
                "type": "string",
                "format": "date-time",
                "nullable": true
              },
              "complaint": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/SupportTicketComplaint"
                  }
                ],
                "nullable": true
              },
              "letters": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/SupportTicketLetterRef"
                }
              },
              "can": {
                "$ref": "#/components/schemas/SupportTicketCan"
              },
              "disclosure_required": {
                "type": "boolean",
                "description": "Always false (no AI on tickets)."
              },
              "requests": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/SupportTicketRequest"
                }
              },
              "messages": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/SupportTicketMessage"
                }
              },
              "next_cursor": {
                "type": "string",
                "nullable": true
              },
              "has_more": {
                "type": "boolean"
              },
              "latest_cursor": {
                "type": "string",
                "nullable": true
              },
              "updated_at": {
                "type": "string",
                "format": "date-time",
                "description": "ETag source."
              },
              "support_availability": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/SupportAvailability"
                  }
                ],
                "nullable": true
              }
            }
          }
        ]
      },
      "SupportTicketTopics": {
        "type": "object",
        "required": ["topics"],
        "properties": {
          "topics": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["code", "attachments"],
              "properties": {
                "code": {
                  "$ref": "#/components/schemas/SupportTicketTopic"
                },
                "attachments": {
                  "type": "boolean"
                }
              }
            }
          }
        }
      },
      "SupportOpenTicketRequest": {
        "type": "object",
        "required": ["client_ticket_id", "topic", "body"],
        "properties": {
          "client_ticket_id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique per customer; replay as ARCH-029a \u00a70.5."
          },
          "topic": {
            "$ref": "#/components/schemas/SupportTicketTopic"
          },
          "subject": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "body": {
            "type": "string",
            "minLength": 1,
            "maxLength": 4000
          },
          "context": {
            "type": "object",
            "required": ["kind", "id"],
            "description": "The customer's own record; another's is dropped silently.",
            "properties": {
              "kind": {
                "type": "string",
                "enum": ["transaction", "card", "account"]
              },
              "id": {
                "type": "string",
                "maxLength": 128
              }
            }
          },
          "upload_ids": {
            "type": "array",
            "maxItems": 5,
            "items": {
              "type": "string",
              "format": "uuid"
            }
          }
        }
      },
      "SupportTicketMessageRequest": {
        "type": "object",
        "required": ["client_message_id", "body"],
        "properties": {
          "client_message_id": {
            "type": "string",
            "format": "uuid"
          },
          "body": {
            "type": "string",
            "minLength": 1,
            "maxLength": 4000
          },
          "upload_ids": {
            "type": "array",
            "maxItems": 5,
            "items": {
              "type": "string",
              "format": "uuid"
            }
          }
        }
      },
      "SupportSubmitRequest": {
        "type": "object",
        "required": ["client_submission_id"],
        "properties": {
          "client_submission_id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique per request."
          },
          "answer": {
            "type": "string",
            "minLength": 1,
            "maxLength": 4000,
            "description": "`answer`: required; `documents`: an optional comment (1 to 1000)."
          },
          "confirm": {
            "type": "boolean",
            "description": "`confirm`: required."
          },
          "files": {
            "type": "array",
            "maxItems": 10,
            "items": {
              "type": "object",
              "required": ["upload_id"],
              "properties": {
                "upload_id": {
                  "type": "string",
                  "format": "uuid"
                },
                "document_type": {
                  "$ref": "#/components/schemas/SupportDocumentType"
                }
              }
            }
          }
        }
      },
      "SupportWithdrawTicketRequest": {
        "type": "object",
        "required": ["client_request_id", "confirm"],
        "properties": {
          "client_request_id": {
            "type": "string",
            "format": "uuid"
          },
          "confirm": {
            "type": "boolean",
            "description": "Must be true."
          },
          "reason": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          }
        }
      },
      "SupportComplaintWithdrawalRequest": {
        "type": "object",
        "required": ["written_request"],
        "properties": {
          "written_request": {
            "type": "object",
            "required": ["received_at", "channel", "evidence_file_id"],
            "properties": {
              "received_at": {
                "type": "string",
                "format": "date-time",
                "description": "When the bank received the written request; not in the future, not before the complaint's registered_at. Becomes `withdrawn_at`."
              },
              "channel": {
                "type": "string",
                "enum": ["email", "letter", "in_person"]
              },
              "evidence_file_id": {
                "type": "string",
                "format": "uuid",
                "description": "A staff upload of purpose `withdrawal_evidence` (the scanned request)."
              }
            }
          },
          "reason": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          }
        }
      },
      "SupportSummary": {
        "type": "object",
        "required": ["thread", "tickets", "letters"],
        "properties": {
          "thread": {
            "type": "object",
            "required": ["enabled", "unread"],
            "properties": {
              "enabled": {
                "type": "boolean"
              },
              "unread": {
                "type": "integer"
              }
            }
          },
          "tickets": {
            "type": "object",
            "required": [
              "enabled",
              "active",
              "waiting_for_you",
              "unread",
              "next_due_date",
              "time_zone"
            ],
            "properties": {
              "enabled": {
                "type": "boolean"
              },
              "active": {
                "type": "integer"
              },
              "waiting_for_you": {
                "type": "integer"
              },
              "unread": {
                "type": "integer"
              },
              "next_due_date": {
                "type": "string",
                "format": "date",
                "nullable": true
              },
              "time_zone": {
                "type": "string",
                "example": "Europe/Madrid"
              }
            }
          },
          "letters": {
            "type": "object",
            "required": ["unread"],
            "properties": {
              "unread": {
                "type": "integer"
              }
            }
          }
        }
      },
      "SupportStaffMessage": {
        "allOf": [
          {
            "$ref": "#/components/schemas/SupportMessage"
          },
          {
            "type": "object",
            "properties": {
              "context": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/SupportMessageContext"
                  }
                ],
                "nullable": true
              },
              "agent_id": {
                "type": "string",
                "format": "uuid",
                "nullable": true
              },
              "macro_id": {
                "type": "string",
                "format": "uuid",
                "nullable": true
              },
              "ai": {
                "type": "object",
                "nullable": true,
                "properties": {
                  "generated_by": {
                    "$ref": "#/components/schemas/SupportGeneratedBy"
                  },
                  "model": {
                    "type": "string",
                    "nullable": true
                  },
                  "prompt_version": {
                    "type": "string",
                    "nullable": true
                  },
                  "trace_ids": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "tool_citations": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "tool": {
                          "type": "string"
                        },
                        "call_id": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              },
              "ai_meta": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/SupportAiMeta"
                  }
                ],
                "nullable": true,
                "description": "What an AI message answered with (0.32.0); null on every other message. Staff only, never in a customer view."
              },
              "feedback": {
                "type": "object",
                "nullable": true,
                "description": "The customer's \"Did that help?\" under this AI answer (0.32.0, migration 243); null without one or on any other message. Staff only.",
                "required": ["helpful", "resolved", "at"],
                "properties": {
                  "helpful": {
                    "type": "boolean"
                  },
                  "resolved": {
                    "type": "boolean",
                    "description": "This \"Yes\" resolved the AI-only case (the thread asked about this answer)."
                  },
                  "at": {
                    "type": "string",
                    "format": "date-time"
                  }
                }
              }
            }
          }
        ]
      },
      "SupportAiMeta": {
        "type": "object",
        "description": "ARCH-029a \u00a74.1 (0.32.0). `tools`: the tool calls of the answer's\nturn in call order, `ok` when the tool returned data (never a\npayload); after the traces' 90 days, the tools the answer cited.\n`sources`: the help articles it cited. `guard`: the server guard's\noutcome; null, as it is not stored per message (an answer the guard\nrefuses is never stored, \u00a77.5).\n",
        "required": [
          "model",
          "prompt_version",
          "generated_by",
          "tools",
          "sources",
          "guard"
        ],
        "properties": {
          "model": {
            "type": "string",
            "nullable": true
          },
          "prompt_version": {
            "type": "string",
            "nullable": true
          },
          "generated_by": {
            "$ref": "#/components/schemas/SupportGeneratedBy"
          },
          "tools": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["name", "ok"],
              "properties": {
                "name": {
                  "type": "string"
                },
                "ok": {
                  "type": "boolean"
                }
              }
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["id", "title"],
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid",
                  "nullable": true
                },
                "title": {
                  "type": "string",
                  "nullable": true
                }
              }
            }
          },
          "guard": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "SupportCaseOperatorList": {
        "type": "object",
        "required": ["operators"],
        "properties": {
          "operators": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["id", "name", "email", "role", "presence"],
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "name": {
                  "type": "string"
                },
                "email": {
                  "type": "string",
                  "nullable": true,
                  "description": "Null unless the caller may assign the case or reads the team view."
                },
                "role": {
                  "type": "string",
                  "enum": [
                    "support_agent",
                    "support_lead",
                    "sac_officer",
                    "mlro",
                    "risk_officer"
                  ]
                },
                "presence": {
                  "type": "string",
                  "nullable": true,
                  "enum": ["available", "away", "offline"],
                  "description": "Null unless the caller may assign the case or reads the team view."
                }
              }
            }
          }
        }
      },
      "SupportStaffMessagePage": {
        "type": "object",
        "required": ["messages", "next_cursor", "has_more", "latest_cursor"],
        "properties": {
          "messages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportStaffMessage"
            }
          },
          "next_cursor": {
            "type": "string",
            "nullable": true
          },
          "has_more": {
            "type": "boolean"
          },
          "latest_cursor": {
            "type": "string",
            "nullable": true
          },
          "has_more_newer": {
            "type": "boolean"
          }
        }
      },
      "SupportNote": {
        "type": "object",
        "required": [
          "id",
          "author_id",
          "author_display_name",
          "body",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "author_id": {
            "type": "string",
            "format": "uuid"
          },
          "author_display_name": {
            "type": "string"
          },
          "body": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SupportTask": {
        "type": "object",
        "required": [
          "id",
          "case_id",
          "title",
          "status",
          "created_by",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "case_id": {
            "type": "string",
            "format": "uuid"
          },
          "title": {
            "type": "string",
            "maxLength": 200
          },
          "queue_code": {
            "type": "string",
            "nullable": true
          },
          "assignee_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "due_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/SupportTaskStatus"
          },
          "created_by": {
            "type": "string",
            "format": "uuid"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SupportCaseEvent": {
        "type": "object",
        "required": ["id", "event_type", "actor", "detail", "created_at"],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "event_type": {
            "$ref": "#/components/schemas/SupportCaseEventType"
          },
          "actor": {
            "type": "object",
            "required": ["type"],
            "properties": {
              "type": {
                "type": "string",
                "enum": ["customer", "agent", "ai", "system", "service"]
              },
              "id": {
                "type": "string",
                "nullable": true
              },
              "role": {
                "type": "string",
                "nullable": true
              }
            }
          },
          "detail": {
            "type": "object",
            "additionalProperties": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SupportCaseDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/SupportCase"
          },
          {
            "type": "object",
            "required": [
              "messages",
              "next_cursor",
              "has_more",
              "notes",
              "tasks",
              "events"
            ],
            "properties": {
              "messages": {
                "type": "array",
                "description": "Newest page of the conversation, oldest first.",
                "items": {
                  "$ref": "#/components/schemas/SupportStaffMessage"
                }
              },
              "next_cursor": {
                "type": "string",
                "nullable": true
              },
              "has_more": {
                "type": "boolean"
              },
              "notes": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/SupportNote"
                }
              },
              "tasks": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/SupportTask"
                }
              },
              "events": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/SupportCaseEvent"
                }
              }
            }
          }
        ]
      },
      "SupportCreateCaseRequest": {
        "type": "object",
        "required": ["customer_id", "type", "channel", "received_at"],
        "properties": {
          "customer_id": {
            "type": "string"
          },
          "type": {
            "$ref": "#/components/schemas/SupportCaseType"
          },
          "channel": {
            "type": "string",
            "enum": ["phone", "email", "letter", "in_person"]
          },
          "received_at": {
            "type": "string",
            "format": "date-time",
            "description": "Not in the future, at most one year back; a complaint's clock starts here."
          },
          "priority": {
            "$ref": "#/components/schemas/SupportPriority"
          },
          "complaint_scope": {
            "$ref": "#/components/schemas/SupportComplaintScope"
          },
          "note": {
            "type": "string",
            "maxLength": 4000,
            "nullable": true,
            "description": "Internal note."
          }
        }
      },
      "SupportAgentReplyRequest": {
        "type": "object",
        "required": ["client_message_id", "body"],
        "properties": {
          "client_message_id": {
            "type": "string",
            "format": "uuid"
          },
          "body": {
            "type": "string",
            "maxLength": 4000
          },
          "macro_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "await_customer": {
            "type": "boolean",
            "default": false,
            "description": "Move the case to waiting_customer (service-level clocks pause)."
          }
        }
      },
      "SupportNoteRequest": {
        "type": "object",
        "required": ["body"],
        "properties": {
          "body": {
            "type": "string",
            "maxLength": 4000
          }
        }
      },
      "SupportTaskRequest": {
        "type": "object",
        "required": ["title"],
        "description": "At least one of queue_code or assignee_id.",
        "properties": {
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "queue_code": {
            "type": "string",
            "nullable": true
          },
          "assignee_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "due_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "SupportTaskPatch": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "queue_code": {
            "type": "string",
            "nullable": true
          },
          "assignee_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "due_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/SupportTaskStatus"
          }
        }
      },
      "SupportAssignRequest": {
        "type": "object",
        "required": ["assignee_id"],
        "properties": {
          "assignee_id": {
            "type": "string",
            "nullable": true,
            "description": "A user id, \"me\" (take), or null (release).",
            "example": "me"
          }
        }
      },
      "SupportEscalateRequest": {
        "type": "object",
        "required": ["queue_code", "reason"],
        "properties": {
          "queue_code": {
            "type": "string"
          },
          "reason": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "note": {
            "type": "string",
            "maxLength": 4000,
            "description": "Internal note (a case note; with a move into or out of compliance it stays with the event in the hidden period)."
          }
        }
      },
      "SupportTransferRequest": {
        "type": "object",
        "required": ["queue_code", "reason"],
        "properties": {
          "queue_code": {
            "type": "string"
          },
          "assignee_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "An operator of the target queue (422 assignee_not_eligible)."
          },
          "reason": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "note": {
            "type": "string",
            "maxLength": 4000
          }
        }
      },
      "SupportLinkKind": {
        "type": "string",
        "enum": [
          "transfer",
          "card",
          "account",
          "kyc_session",
          "compliance_case",
          "related_case"
        ]
      },
      "SupportCaseLink": {
        "type": "object",
        "required": ["id", "kind", "ref_id", "created_at"],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "kind": {
            "$ref": "#/components/schemas/SupportLinkKind"
          },
          "ref_id": {
            "type": "string"
          },
          "label": {
            "type": "string",
            "nullable": true,
            "description": "A short identifier: counterparty or reference, masked card, IBAN or wallet name, KYC provider and status, compliance case type, case reference."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SupportWatcher": {
        "type": "object",
        "required": ["user_id", "display_name", "since"],
        "properties": {
          "user_id": {
            "type": "string",
            "format": "uuid"
          },
          "display_name": {
            "type": "string"
          },
          "since": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SupportWatcherList": {
        "type": "object",
        "required": ["watchers"],
        "properties": {
          "watchers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportWatcher"
            }
          }
        }
      },
      "SupportActivityKind": {
        "type": "string",
        "description": "ARCH-030 \u00a72; clients treat an unknown value as `status`.",
        "enum": [
          "message",
          "note",
          "request",
          "submission",
          "review",
          "file",
          "status",
          "assignment",
          "transfer",
          "watcher",
          "link",
          "letter",
          "complaint",
          "sla",
          "task"
        ]
      },
      "SupportActivity": {
        "type": "object",
        "required": ["id", "at", "kind", "actor", "detail"],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "at": {
            "type": "string",
            "format": "date-time"
          },
          "kind": {
            "$ref": "#/components/schemas/SupportActivityKind"
          },
          "actor": {
            "type": "object",
            "required": ["type"],
            "properties": {
              "type": {
                "type": "string",
                "enum": ["customer", "ai", "agent", "system", "service"]
              },
              "id": {
                "type": "string",
                "nullable": true
              },
              "role": {
                "type": "string",
                "nullable": true
              },
              "display_name": {
                "type": "string",
                "nullable": true
              }
            }
          },
          "detail": {
            "type": "object",
            "additionalProperties": true,
            "description": "Events: `event_type` and the event detail as the case detail shows it (with `reason` where the viewer may see it). Messages: `message_id`, `author`, `message_kind`, `preview`. Notes: `note_id`, `body`. Tasks: `task_id`, `title`, `status`, `queue_code`, `assignee_id`, `change`."
          }
        }
      },
      "SupportActivityPage": {
        "type": "object",
        "required": ["activity", "next_cursor", "has_more"],
        "properties": {
          "activity": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportActivity"
            }
          },
          "next_cursor": {
            "type": "string",
            "nullable": true
          },
          "has_more": {
            "type": "boolean"
          }
        }
      },
      "SupportSavedView": {
        "type": "object",
        "required": [
          "id",
          "name",
          "scope",
          "filters",
          "sort",
          "columns",
          "read_only"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "A uuid, or `system:<key>` for a system view."
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 60
          },
          "scope": {
            "type": "string",
            "enum": ["personal", "queue", "system"]
          },
          "queue_code": {
            "type": "string",
            "nullable": true
          },
          "filters": {
            "type": "object",
            "additionalProperties": true,
            "description": "GET /cases parameters: a string, or an array of strings for the repeatable ones."
          },
          "sort": {
            "type": "string",
            "enum": ["due", "updated", "created"]
          },
          "columns": {
            "type": "array",
            "maxItems": 20,
            "items": {
              "type": "string"
            }
          },
          "owner_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "read_only": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SupportSavedViewInput": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 60
          },
          "scope": {
            "type": "string",
            "enum": ["personal", "queue"],
            "default": "personal",
            "description": "POST only."
          },
          "queue_code": {
            "type": "string",
            "description": "POST only, required with scope queue."
          },
          "filters": {
            "type": "object",
            "additionalProperties": true
          },
          "sort": {
            "type": "string",
            "enum": ["due", "updated", "created"],
            "default": "due"
          },
          "columns": {
            "type": "array",
            "maxItems": 20,
            "items": {
              "type": "string"
            }
          }
        }
      },
      "SupportBulkRequest": {
        "type": "object",
        "required": ["case_ids", "action"],
        "properties": {
          "case_ids": {
            "type": "array",
            "minItems": 1,
            "maxItems": 100,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "format": "uuid"
            }
          },
          "action": {
            "type": "string",
            "enum": ["assign", "transfer", "add_watcher", "set_priority"]
          },
          "params": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "SupportBulkResult": {
        "type": "object",
        "required": ["results"],
        "properties": {
          "results": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["case_id", "ok", "error"],
              "properties": {
                "case_id": {
                  "type": "string",
                  "format": "uuid"
                },
                "ok": {
                  "type": "boolean"
                },
                "error": {
                  "type": "object",
                  "nullable": true,
                  "properties": {
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "SupportStatusRequest": {
        "type": "object",
        "required": ["status"],
        "properties": {
          "status": {
            "type": "string",
            "enum": ["queued", "waiting_customer", "assigned", "resolved"]
          },
          "reason": {
            "type": "string",
            "maxLength": 500,
            "nullable": true
          },
          "resolution": {
            "type": "string",
            "minLength": 1,
            "maxLength": 1000,
            "description": "Tickets, `resolved` only and required (ARCH-030 \u00a76.6); shown to the customer."
          },
          "resolution_code": {
            "$ref": "#/components/schemas/SupportResolutionCode"
          },
          "cancel_open_requests": {
            "type": "boolean",
            "default": false,
            "description": "Tickets: cancel pending and rejected requests with the resolution."
          }
        }
      },
      "SupportClassifyRequest": {
        "type": "object",
        "properties": {
          "type": {
            "$ref": "#/components/schemas/SupportCaseType"
          },
          "priority": {
            "$ref": "#/components/schemas/SupportPriority"
          },
          "complaint_message_id": {
            "type": "string",
            "format": "uuid",
            "description": "Required when type becomes complaint; the first customer message that expressed it."
          },
          "complaint_scope": {
            "$ref": "#/components/schemas/SupportComplaintScope"
          },
          "tipping_off_lock": {
            "type": "boolean",
            "description": "Cleared only by mlro."
          },
          "vulnerability": {
            "type": "boolean"
          },
          "reason": {
            "type": "string",
            "maxLength": 500,
            "description": "Required to remove the complaint type (sac_officer)."
          }
        }
      },
      "SupportCustomerContext": {
        "type": "object",
        "required": [
          "customer",
          "accounts",
          "recent_transactions",
          "cards",
          "holds",
          "tickets",
          "history"
        ],
        "properties": {
          "tickets": {
            "type": "array",
            "maxItems": 20,
            "items": {
              "$ref": "#/components/schemas/SupportCustomerTicketRef"
            }
          },
          "history": {
            "type": "array",
            "maxItems": 10,
            "items": {
              "$ref": "#/components/schemas/SupportCustomerHistoryItem"
            }
          },
          "customer": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "type": {
                "type": "string",
                "enum": ["individual", "business"]
              },
              "display_name": {
                "type": "string"
              },
              "email": {
                "type": "string",
                "nullable": true
              },
              "phone": {
                "type": "string",
                "nullable": true
              },
              "language": {
                "type": "string",
                "nullable": true
              },
              "status": {
                "type": "string"
              },
              "kyc_status": {
                "type": "string",
                "nullable": true
              },
              "created_at": {
                "type": "string",
                "format": "date-time"
              }
            }
          },
          "accounts": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "iban": {
                  "type": "string",
                  "nullable": true
                },
                "currency": {
                  "type": "string"
                },
                "balance_minor": {
                  "type": "integer",
                  "format": "int64",
                  "nullable": true,
                  "description": "Available balance in minor units; null when the ledger cannot be read."
                },
                "status": {
                  "type": "string"
                }
              }
            }
          },
          "recent_transactions": {
            "type": "array",
            "maxItems": 20,
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "created_at": {
                  "type": "string",
                  "format": "date-time"
                },
                "amount_minor": {
                  "type": "integer",
                  "format": "int64"
                },
                "currency": {
                  "type": "string"
                },
                "direction": {
                  "type": "string",
                  "enum": ["in", "out"]
                },
                "status": {
                  "type": "string"
                },
                "rail": {
                  "type": "string"
                },
                "counterparty_name": {
                  "type": "string",
                  "nullable": true
                },
                "on_hold": {
                  "type": "boolean"
                }
              }
            }
          },
          "cards": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "last4": {
                  "type": "string"
                },
                "type": {
                  "type": "string",
                  "enum": ["virtual", "physical"]
                },
                "status": {
                  "type": "string"
                }
              }
            }
          },
          "holds": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "transfer_id": {
                  "type": "string"
                },
                "amount_minor": {
                  "type": "integer",
                  "format": "int64"
                },
                "currency": {
                  "type": "string"
                },
                "since": {
                  "type": "string",
                  "format": "date-time"
                },
                "reason": {
                  "type": "string",
                  "nullable": true,
                  "description": "mlro only; null for every other role."
                },
                "compliance_case_id": {
                  "type": "string",
                  "nullable": true,
                  "description": "mlro only."
                }
              }
            }
          }
        }
      },
      "SupportCustomerHistoryItem": {
        "type": "object",
        "description": "Another chat or ticket of the customer the caller may see (helpdesk UX review).",
        "required": [
          "id",
          "reference",
          "kind",
          "type",
          "status",
          "created_at",
          "ended_at",
          "about",
          "last_message",
          "text_hidden"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "reference": {
            "type": "string"
          },
          "kind": {
            "$ref": "#/components/schemas/SupportCaseKind"
          },
          "type": {
            "$ref": "#/components/schemas/SupportCaseType"
          },
          "status": {
            "$ref": "#/components/schemas/SupportCaseStatus"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "ended_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "queue_label": {
            "type": "string",
            "nullable": true
          },
          "handled_by": {
            "type": "string",
            "nullable": true,
            "description": "The assignee's display name."
          },
          "ai_handoff": {
            "type": "boolean",
            "description": "The AI handed it to people."
          },
          "complaint_reference": {
            "type": "string",
            "nullable": true
          },
          "complaint_outcome": {
            "type": "string",
            "nullable": true
          },
          "resolution_code": {
            "type": "string",
            "nullable": true
          },
          "close_reason": {
            "type": "string",
            "nullable": true
          },
          "ticket_topic": {
            "type": "string",
            "nullable": true
          },
          "about": {
            "type": "string",
            "nullable": true,
            "description": "A ticket's subject or a chat's first question (excerpt); null when `text_hidden`."
          },
          "last_message": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportCasePreview"
              }
            ],
            "nullable": true
          },
          "rating": {
            "type": "integer",
            "minimum": 1,
            "maximum": 5,
            "nullable": true
          },
          "text_hidden": {
            "type": "boolean",
            "description": "No words on the list: a locked or compliance-queue case (mlro, auditor only), or a case with the silent compliance marker (every other role; outcome fields null as well)."
          }
        }
      },
      "SupportCustomerMatches": {
        "type": "object",
        "required": ["customers"],
        "properties": {
          "customers": {
            "type": "array",
            "maxItems": 20,
            "items": {
              "type": "object",
              "required": ["id", "display_name", "type", "status"],
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "display_name": {
                  "type": "string"
                },
                "type": {
                  "type": "string",
                  "enum": ["individual", "business"]
                },
                "email": {
                  "type": "string",
                  "nullable": true
                },
                "status": {
                  "type": "string"
                },
                "kyc_status": {
                  "type": "string",
                  "nullable": true
                },
                "iban": {
                  "type": "string",
                  "nullable": true
                },
                "language": {
                  "type": "string",
                  "nullable": true
                }
              }
            }
          }
        }
      },
      "SupportCustomerTransfers": {
        "type": "object",
        "required": ["transfers"],
        "properties": {
          "transfers": {
            "type": "array",
            "maxItems": 20,
            "items": {
              "type": "object",
              "required": [
                "id",
                "created_at",
                "amount_minor",
                "currency",
                "direction"
              ],
              "properties": {
                "id": {
                  "type": "string"
                },
                "created_at": {
                  "type": "string",
                  "format": "date-time"
                },
                "amount_minor": {
                  "type": "integer",
                  "format": "int64",
                  "nullable": true
                },
                "currency": {
                  "type": "string",
                  "nullable": true
                },
                "direction": {
                  "type": "string",
                  "enum": ["in", "out"]
                },
                "status": {
                  "type": "string",
                  "nullable": true
                },
                "rail": {
                  "type": "string",
                  "nullable": true
                },
                "counterparty_name": {
                  "type": "string",
                  "nullable": true
                }
              }
            }
          }
        }
      },
      "SupportEraseRequest": {
        "type": "object",
        "required": ["confirm"],
        "properties": {
          "confirm": {
            "type": "boolean",
            "enum": [true]
          }
        }
      },
      "SupportEraseResult": {
        "type": "object",
        "required": ["messages_erased", "notes_erased", "complaint_cases_kept"],
        "properties": {
          "messages_erased": {
            "type": "integer"
          },
          "notes_erased": {
            "type": "integer"
          },
          "complaint_cases_kept": {
            "type": "integer"
          }
        }
      },
      "SupportDashboard": {
        "type": "object",
        "required": [
          "open_by_queue",
          "statutory_due_this_week",
          "statutory_breached",
          "generated_at"
        ],
        "properties": {
          "open_by_queue": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "queue_code",
                "queue_label",
                "open",
                "unassigned",
                "due_soon",
                "breached"
              ],
              "properties": {
                "queue_code": {
                  "type": "string"
                },
                "queue_label": {
                  "type": "string",
                  "description": "The queue's name as the bank set it."
                },
                "open": {
                  "type": "integer"
                },
                "unassigned": {
                  "type": "integer"
                },
                "due_soon": {
                  "type": "integer"
                },
                "breached": {
                  "type": "integer"
                }
              }
            }
          },
          "statutory_due_this_week": {
            "type": "integer"
          },
          "statutory_breached": {
            "type": "integer"
          },
          "generated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SupportHoldingReplyRequest": {
        "type": "object",
        "required": ["client_message_id", "body", "final_reply_by"],
        "properties": {
          "client_message_id": {
            "type": "string",
            "format": "uuid"
          },
          "body": {
            "type": "string",
            "maxLength": 4000,
            "description": "The reasons for the delay."
          },
          "final_reply_by": {
            "type": "string",
            "format": "date",
            "description": "After today, not after reply_by_latest (tenant calendar date)."
          }
        }
      },
      "SupportFinalReplyRequest": {
        "type": "object",
        "required": ["client_message_id", "body", "outcome"],
        "properties": {
          "client_message_id": {
            "type": "string",
            "format": "uuid"
          },
          "body": {
            "type": "string",
            "maxLength": 4000,
            "description": "The reasons for the outcome. The bank appends the tenant's escalation text for the customer's language."
          },
          "outcome": {
            "$ref": "#/components/schemas/SupportComplaintOutcome"
          }
        }
      },
      "SupportRegisterEvent": {
        "type": "object",
        "required": [
          "id",
          "kind",
          "occurred_at",
          "note",
          "created_by",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "kind": {
            "type": "string",
            "enum": [
              "supervisor_escalation",
              "correction",
              "reclassified",
              "withdrawn"
            ],
            "description": "`withdrawn`: written by a complaint withdrawal (ARCH-030 \u00a74.4), never through POST register-events."
          },
          "occurred_at": {
            "type": "string",
            "format": "date-time"
          },
          "note": {
            "type": "string"
          },
          "field": {
            "type": "string",
            "nullable": true
          },
          "value": {
            "type": "string",
            "nullable": true
          },
          "created_by": {
            "type": "string",
            "format": "uuid"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SupportRegisterEventRequest": {
        "type": "object",
        "required": ["kind", "occurred_at", "note"],
        "properties": {
          "kind": {
            "type": "string",
            "enum": ["supervisor_escalation", "correction", "reclassified"]
          },
          "occurred_at": {
            "type": "string",
            "format": "date-time"
          },
          "note": {
            "type": "string",
            "minLength": 1,
            "maxLength": 1000
          },
          "field": {
            "type": "string",
            "nullable": true
          },
          "value": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "SupportRegisterEntry": {
        "type": "object",
        "description": "One complaint in the register (BR-AP-024 FR-11). CSV columns are these fields in this order, without events and `customer_name`.",
        "required": [
          "case_id",
          "reference",
          "customer_id",
          "received_at",
          "channel",
          "type",
          "scope",
          "product",
          "statutory_kind",
          "statutory_due_date"
        ],
        "properties": {
          "case_id": {
            "type": "string",
            "format": "uuid"
          },
          "reference": {
            "type": "string"
          },
          "customer_id": {
            "type": "string"
          },
          "customer_name": {
            "type": "string",
            "nullable": true,
            "description": "JSON only."
          },
          "received_at": {
            "type": "string",
            "format": "date-time"
          },
          "channel": {
            "$ref": "#/components/schemas/SupportChannel"
          },
          "type": {
            "$ref": "#/components/schemas/SupportCaseType"
          },
          "scope": {
            "$ref": "#/components/schemas/SupportComplaintScope"
          },
          "product": {
            "type": "string",
            "enum": ["transfer", "card", "account", "other"]
          },
          "statutory_kind": {
            "$ref": "#/components/schemas/SupportStatutoryKind"
          },
          "statutory_due_date": {
            "type": "string",
            "format": "date"
          },
          "holding_reply_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "final_reply_by": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "final_reply_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "outcome": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportComplaintOutcomeRecorded"
              }
            ],
            "nullable": true
          },
          "business_days_to_answer": {
            "type": "integer",
            "nullable": true,
            "description": "Null while open and for a withdrawn complaint."
          },
          "within_deadline": {
            "type": "boolean",
            "nullable": true,
            "description": "Null while open and for a withdrawn complaint."
          },
          "escalated_to_supervisor_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "withdrawn_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "withdrawal_by": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportWithdrawalBy"
              }
            ],
            "nullable": true
          },
          "withdrawal_channel": {
            "type": "string",
            "enum": ["in_app", "email", "letter", "in_person"],
            "nullable": true
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportRegisterEvent"
            }
          }
        }
      },
      "SupportRegisterPage": {
        "type": "object",
        "required": ["entries", "next_cursor", "has_more"],
        "properties": {
          "entries": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportRegisterEntry"
            }
          },
          "next_cursor": {
            "type": "string",
            "nullable": true
          },
          "has_more": {
            "type": "boolean"
          }
        }
      },
      "SupportSacAnnualReport": {
        "type": "object",
        "required": [
          "year",
          "time_zone",
          "totals",
          "by_type",
          "by_product",
          "by_outcome",
          "main_causes"
        ],
        "properties": {
          "year": {
            "type": "integer"
          },
          "time_zone": {
            "type": "string"
          },
          "totals": {
            "type": "object",
            "properties": {
              "received": {
                "type": "integer"
              },
              "answered": {
                "type": "integer"
              },
              "within_deadline_share": {
                "type": "number",
                "minimum": 0,
                "maximum": 1
              },
              "avg_business_days": {
                "type": "number"
              },
              "max_business_days": {
                "type": "integer"
              },
              "escalated_to_supervisor": {
                "type": "integer"
              },
              "withdrawn": {
                "type": "integer",
                "description": "Withdrawn complaints (ARCH-030 \u00a714); `answered`, the share and the averages count answered complaints only; `by_outcome` lists `withdrawn`."
              }
            }
          },
          "by_type": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string"
                },
                "count": {
                  "type": "integer"
                }
              }
            }
          },
          "by_product": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "product": {
                  "type": "string"
                },
                "count": {
                  "type": "integer"
                }
              }
            }
          },
          "by_outcome": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "outcome": {
                  "type": "string"
                },
                "count": {
                  "type": "integer"
                }
              }
            }
          },
          "main_causes": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string"
                },
                "count": {
                  "type": "integer"
                }
              }
            }
          }
        }
      },
      "SupportQueue": {
        "type": "object",
        "required": [
          "id",
          "code",
          "label",
          "work_roles",
          "read_roles",
          "case_types",
          "active",
          "sort",
          "seeded"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "code": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]{1,31}$"
          },
          "label": {
            "type": "string",
            "maxLength": 80
          },
          "work_roles": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportRole"
            }
          },
          "read_roles": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportRole"
            }
          },
          "case_types": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportCaseType"
            }
          },
          "active": {
            "type": "boolean"
          },
          "sort": {
            "type": "integer"
          },
          "seeded": {
            "type": "boolean",
            "description": "Seeded queues keep their code and stay active."
          }
        }
      },
      "SupportQueueInput": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]{1,31}$",
            "description": "POST only."
          },
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80
          },
          "work_roles": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportRole"
            }
          },
          "read_roles": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportRole"
            }
          },
          "case_types": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportCaseType"
            }
          },
          "active": {
            "type": "boolean"
          },
          "sort": {
            "type": "integer"
          }
        }
      },
      "SupportSlaPolicy": {
        "type": "object",
        "required": [
          "id",
          "case_type",
          "priority",
          "first_response_minutes",
          "next_response_minutes",
          "resolution_minutes",
          "due_soon_minutes",
          "active"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "case_type": {
            "type": "string",
            "description": "A case type or \"*\"."
          },
          "priority": {
            "type": "string",
            "description": "A priority or \"*\"."
          },
          "first_response_minutes": {
            "type": "integer",
            "minimum": 1,
            "maximum": 43200
          },
          "next_response_minutes": {
            "type": "integer",
            "minimum": 1,
            "maximum": 43200
          },
          "resolution_minutes": {
            "type": "integer",
            "minimum": 1,
            "maximum": 43200
          },
          "due_soon_minutes": {
            "type": "integer",
            "minimum": 1,
            "maximum": 43200,
            "default": 60
          },
          "active": {
            "type": "boolean"
          },
          "queue_code": {
            "type": "string",
            "description": "A queue code or \"*\" (every queue, ARCH-030 \u00a77.6)."
          }
        }
      },
      "SupportSlaPolicyInput": {
        "type": "object",
        "properties": {
          "queue_code": {
            "type": "string",
            "default": "*",
            "description": "POST only: a queue code or *."
          },
          "case_type": {
            "type": "string"
          },
          "priority": {
            "type": "string"
          },
          "first_response_minutes": {
            "type": "integer",
            "minimum": 1,
            "maximum": 43200
          },
          "next_response_minutes": {
            "type": "integer",
            "minimum": 1,
            "maximum": 43200
          },
          "resolution_minutes": {
            "type": "integer",
            "minimum": 1,
            "maximum": 43200
          },
          "due_soon_minutes": {
            "type": "integer",
            "minimum": 1,
            "maximum": 43200
          },
          "active": {
            "type": "boolean"
          }
        }
      },
      "SupportHoliday": {
        "type": "object",
        "required": ["date", "name", "scope"],
        "properties": {
          "date": {
            "type": "string",
            "format": "date"
          },
          "name": {
            "type": "string",
            "maxLength": 80
          },
          "scope": {
            "type": "string",
            "enum": ["national", "regional", "tenant"]
          }
        }
      },
      "SupportCalendar": {
        "type": "object",
        "required": ["time_zone", "working_days", "business_hours", "holidays"],
        "properties": {
          "time_zone": {
            "type": "string",
            "example": "Europe/Madrid"
          },
          "working_days": {
            "type": "array",
            "description": "ISO weekdays, 1 = Monday.",
            "items": {
              "type": "integer",
              "minimum": 1,
              "maximum": 7
            },
            "example": [1, 2, 3, 4, 5]
          },
          "business_hours": {
            "type": "object",
            "required": ["start", "end"],
            "properties": {
              "start": {
                "type": "string",
                "pattern": "^([01][0-9]|2[0-3]):[0-5][0-9]$",
                "example": "09:00"
              },
              "end": {
                "type": "string",
                "pattern": "^([01][0-9]|2[0-3]):[0-5][0-9]$",
                "example": "18:00"
              }
            }
          },
          "holidays": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportHoliday"
            }
          }
        }
      },
      "SupportCalendarPatch": {
        "type": "object",
        "properties": {
          "time_zone": {
            "type": "string"
          },
          "working_days": {
            "type": "array",
            "items": {
              "type": "integer",
              "minimum": 1,
              "maximum": 7
            }
          },
          "business_hours": {
            "type": "object",
            "properties": {
              "start": {
                "type": "string"
              },
              "end": {
                "type": "string"
              }
            }
          }
        }
      },
      "SupportHolidayInput": {
        "type": "object",
        "required": ["date", "name", "scope"],
        "properties": {
          "date": {
            "type": "string",
            "format": "date"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80
          },
          "scope": {
            "type": "string",
            "enum": ["regional", "tenant"]
          }
        }
      },
      "SupportMacro": {
        "type": "object",
        "required": [
          "id",
          "locale",
          "title",
          "body",
          "case_types",
          "active",
          "version",
          "updated_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "locale": {
            "$ref": "#/components/schemas/SupportLocale"
          },
          "title": {
            "type": "string",
            "maxLength": 120
          },
          "body": {
            "type": "string",
            "maxLength": 4000
          },
          "case_types": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportCaseType"
            }
          },
          "active": {
            "type": "boolean"
          },
          "version": {
            "type": "integer"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SupportMacroInput": {
        "type": "object",
        "properties": {
          "locale": {
            "$ref": "#/components/schemas/SupportLocale"
          },
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "body": {
            "type": "string",
            "maxLength": 4000
          },
          "case_types": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportCaseType"
            }
          },
          "active": {
            "type": "boolean"
          }
        }
      },
      "SupportHelpArticleAdmin": {
        "type": "object",
        "required": [
          "id",
          "locale",
          "slug",
          "title",
          "body",
          "status",
          "version",
          "updated_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "locale": {
            "$ref": "#/components/schemas/SupportLocale"
          },
          "slug": {
            "type": "string",
            "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$",
            "maxLength": 80
          },
          "title": {
            "type": "string",
            "maxLength": 160
          },
          "body": {
            "type": "string",
            "maxLength": 20000
          },
          "status": {
            "type": "string",
            "enum": ["draft", "published", "archived"]
          },
          "version": {
            "type": "integer"
          },
          "published_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SupportHelpArticleInput": {
        "type": "object",
        "properties": {
          "locale": {
            "$ref": "#/components/schemas/SupportLocale"
          },
          "slug": {
            "type": "string",
            "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$",
            "maxLength": 80
          },
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 160
          },
          "body": {
            "type": "string",
            "minLength": 1,
            "maxLength": 20000
          },
          "status": {
            "type": "string",
            "enum": ["draft", "archived"]
          }
        }
      },
      "SupportComplaintPeriod": {
        "type": "object",
        "required": ["unit", "value"],
        "properties": {
          "unit": {
            "type": "string",
            "enum": ["months", "business_days", "calendar_days"]
          },
          "value": {
            "type": "integer",
            "minimum": 1,
            "maximum": 90
          }
        }
      },
      "SupportSettings": {
        "type": "object",
        "description": "Tenant support settings (ARCH-029a \u00a72.2).",
        "properties": {
          "support_chat": {
            "type": "boolean",
            "readOnly": true,
            "description": "Tenant feature (PATCH /tenants/{id}/features)."
          },
          "support_ai": {
            "type": "boolean",
            "readOnly": true,
            "description": "Tenant feature (PATCH /tenants/{id}/features)."
          },
          "complaint_regime": {
            "type": "string",
            "enum": ["es", "tenant_policy"]
          },
          "tenant_complaint_period": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportComplaintPeriod"
              }
            ],
            "nullable": true
          },
          "statutory_warning_business_days": {
            "type": "integer",
            "minimum": 1,
            "maximum": 10,
            "default": 3
          },
          "reopen_window_days": {
            "type": "integer",
            "minimum": 1,
            "maximum": 30,
            "default": 7
          },
          "ai_idle_resolve_hours": {
            "type": "integer",
            "minimum": 1,
            "maximum": 168,
            "default": 24
          },
          "show_expected_reply": {
            "type": "boolean",
            "default": true
          },
          "show_availability": {
            "type": "boolean",
            "default": true,
            "description": "Send support_availability to customers (0.26.0). Off - the block is null; the AI never names hours."
          },
          "csat_enabled": {
            "type": "boolean",
            "default": true
          },
          "escalation_texts": {
            "type": "object",
            "description": "Locale (en, es, de, pt, ar) to text of at most 1000 characters; appended to every final reply.",
            "additionalProperties": {
              "type": "string",
              "maxLength": 1000
            }
          },
          "complaint_retention_days": {
            "type": "integer",
            "minimum": 1,
            "nullable": true,
            "description": "NULL keeps complaint records (never anonymised). A period is at\nleast `complaint_floor.retention_min_days` (422 `complaint_floor`,\nfield `complaint_retention_days`, migration 279).\n"
          },
          "complaint_floor": {
            "type": "object",
            "readOnly": true,
            "description": "The floor of the bank's jurisdiction (migration 279): a statutory\ncomplaint regime the bank keeps (`es` for Spain; a PATCH to\n`tenant_policy` is 422 `complaint_floor`, field\n`complaint_regime`), and the shortest complaint retention in days.\n",
            "properties": {
              "statutory_regime": {
                "type": "string",
                "enum": ["es"],
                "nullable": true
              },
              "retention_min_days": {
                "type": "integer"
              }
            }
          },
          "support_tickets": {
            "type": "boolean",
            "readOnly": true,
            "description": "Tenant feature (ARCH-030 \u00a73.1), independent of support_chat."
          },
          "ticket_default_due_days": {
            "type": "integer",
            "minimum": 1,
            "maximum": 90,
            "default": 14
          },
          "ticket_reminder_days": {
            "type": "array",
            "maxItems": 3,
            "uniqueItems": true,
            "items": {
              "type": "integer",
              "minimum": 1,
              "maximum": 30
            },
            "default": [3, 1]
          },
          "customer_open_ticket_limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 50,
            "default": 10
          },
          "restricted_terms": {
            "type": "object",
            "description": "Locale to at most 100 terms (2 to 60 characters) the wording check refuses on kyc, risk and aml_rfi tickets (ARCH-030 \u00a712.3). Sent to bank_admin, mlro and auditor only.",
            "additionalProperties": {
              "type": "array",
              "maxItems": 100,
              "items": {
                "type": "string",
                "minLength": 2,
                "maxLength": 60
              }
            }
          }
        }
      },
      "SupportAiSettings": {
        "type": "object",
        "description": "AI first-line settings (ARCH-029a \u00a76.7).",
        "required": [
          "enabled",
          "available",
          "models",
          "evaluated_locales",
          "monthly_token_cap",
          "tokens_used",
          "cap_reached"
        ],
        "properties": {
          "enabled": {
            "type": "boolean",
            "readOnly": true
          },
          "available": {
            "type": "boolean",
            "readOnly": true
          },
          "note": {
            "type": "string",
            "enum": [
              "no_model_endpoint",
              "evaluation_missing",
              "templates_only",
              "templates_unevaluated_locales"
            ],
            "nullable": true,
            "description": "templates_only: production without a ZDR model endpoint; the AI first line answers from rules and help articles and calls no model (ARCH-029a \u00a72.1)."
          },
          "models": {
            "type": "object",
            "readOnly": true,
            "properties": {
              "chat": {
                "type": "string"
              },
              "utility": {
                "type": "string"
              },
              "moderation": {
                "type": "string"
              },
              "embed": {
                "type": "string",
                "nullable": true
              }
            }
          },
          "evaluated_locales": {
            "type": "array",
            "readOnly": true,
            "items": {
              "type": "object",
              "properties": {
                "locale": {
                  "type": "string"
                },
                "passed_at": {
                  "type": "string",
                  "format": "date-time"
                },
                "report_id": {
                  "type": "string"
                }
              }
            }
          },
          "monthly_token_cap": {
            "type": "integer",
            "format": "int64",
            "minimum": 0,
            "nullable": true,
            "description": "The effective monthly token cap: null no cap, 0 no AI turns (DEC-0034)."
          },
          "tokens_used": {
            "type": "integer",
            "format": "int64",
            "readOnly": true,
            "description": "Tokens this calendar month (UTC) from finance_ai_token_usage; the trace retention never lowers it."
          },
          "period_start": {
            "type": "string",
            "format": "date",
            "readOnly": true
          },
          "cap_reached": {
            "type": "boolean",
            "readOnly": true
          },
          "neutral_sentences": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "maxLength": 300
            }
          },
          "extra_handoff_triggers": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "type": "object",
              "required": ["locale", "phrase"],
              "properties": {
                "locale": {
                  "type": "string"
                },
                "phrase": {
                  "type": "string",
                  "minLength": 2,
                  "maxLength": 80
                }
              }
            }
          },
          "mandatory_triggers": {
            "type": "array",
            "readOnly": true,
            "items": {
              "$ref": "#/components/schemas/SupportHandoffReason"
            }
          },
          "policy": {
            "allOf": [
              {
                "$ref": "#/components/schemas/TenantAiPolicy"
              }
            ],
            "readOnly": true,
            "description": "The tenant's effective AI policy and its layers (ARCH-029a \u00a711.5)."
          }
        }
      },
      "SupportMetrics": {
        "type": "object",
        "description": "Team metrics of one window (ARCH-029a \u00a76.8, 0.32.0). No figure names a person.",
        "required": [
          "window",
          "queue",
          "volumes",
          "ai",
          "first_response",
          "resolution",
          "sla_breaches",
          "csat",
          "helpful",
          "basis",
          "generated_at"
        ],
        "properties": {
          "window": {
            "type": "object",
            "required": ["from", "to"],
            "properties": {
              "from": {
                "type": "string",
                "format": "date-time"
              },
              "to": {
                "type": "string",
                "format": "date-time",
                "description": "Exclusive."
              }
            }
          },
          "queue": {
            "type": "string",
            "nullable": true
          },
          "volumes": {
            "type": "object",
            "required": ["chat", "ticket", "complaint", "customer", "bank"],
            "properties": {
              "chat": {
                "type": "integer"
              },
              "ticket": {
                "type": "integer"
              },
              "complaint": {
                "type": "integer"
              },
              "customer": {
                "type": "integer"
              },
              "bank": {
                "type": "integer"
              }
            }
          },
          "ai": {
            "type": "object",
            "required": ["resolved", "handed_off"],
            "properties": {
              "resolved": {
                "type": "integer"
              },
              "handed_off": {
                "type": "integer"
              }
            }
          },
          "first_response": {
            "$ref": "#/components/schemas/SupportMetricsDurations"
          },
          "resolution": {
            "$ref": "#/components/schemas/SupportMetricsDurations"
          },
          "sla_breaches": {
            "type": "integer"
          },
          "csat": {
            "type": "object",
            "required": ["avg", "count", "suppressed"],
            "properties": {
              "avg": {
                "type": "number",
                "nullable": true,
                "description": "To two decimals; null without a rating or for 1 to 4 ratings."
              },
              "count": {
                "type": "integer"
              },
              "suppressed": {
                "type": "boolean",
                "description": "True when 1 to 4 ratings would make the average (it is then null)."
              }
            }
          },
          "helpful": {
            "type": "object",
            "required": ["yes", "no"],
            "properties": {
              "yes": {
                "type": "integer"
              },
              "no": {
                "type": "integer"
              }
            }
          },
          "basis": {
            "type": "string",
            "enum": ["business_hours", "wall"]
          },
          "generated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SupportMetricsDurations": {
        "type": "object",
        "required": ["median_min", "p90_min", "count", "suppressed"],
        "properties": {
          "median_min": {
            "type": "number",
            "nullable": true,
            "description": "Minutes (one decimal), interpolated as percentile_cont; null without a case or for 1 to 4 cases."
          },
          "p90_min": {
            "type": "number",
            "nullable": true
          },
          "count": {
            "type": "integer"
          },
          "suppressed": {
            "type": "boolean",
            "description": "True when 1 to 4 cases would make the figures (they are then null; DEC-0033 decision 32)."
          }
        }
      },
      "SupportTurnContext": {
        "type": "object",
        "description": "Context of one AI turn (ARCH-029a \u00a77.1). Raw text goes to the\ngateway's memory only, never into a Restate journal entry.\n",
        "required": [
          "turn_id",
          "conversation_id",
          "customer_id",
          "case_id",
          "language",
          "pending_messages",
          "history",
          "known_entities",
          "case",
          "ai",
          "client_actions",
          "tokens"
        ],
        "properties": {
          "turn_id": {
            "type": "string",
            "format": "uuid"
          },
          "conversation_id": {
            "type": "string",
            "format": "uuid"
          },
          "customer_id": {
            "type": "string"
          },
          "case_id": {
            "type": "string",
            "format": "uuid"
          },
          "language": {
            "type": "string"
          },
          "locale": {
            "type": "string",
            "nullable": true
          },
          "pending_messages": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "body": {
                  "type": "string"
                },
                "created_at": {
                  "type": "string",
                  "format": "date-time"
                },
                "context": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SupportMessageContext"
                    }
                  ],
                  "nullable": true
                },
                "intent": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SupportMessageIntent"
                    }
                  ],
                  "nullable": true,
                  "description": "0.28.1: the chip the customer tapped with the context."
                }
              }
            }
          },
          "standing_context": {
            "type": "array",
            "description": "0.28.1: the open case's payment (`transaction`) and card, on every turn, so a follow-up keeps them. 0.28.1: the payment is `transaction` whatever the bank's hold on it; `bank_hold` only when the customer wrote about it from a hold notice in this case (then the restricted route, like a message context).",
            "items": {
              "$ref": "#/components/schemas/SupportMessageContext"
            }
          },
          "history": {
            "type": "array",
            "maxItems": 12,
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "author": {
                  "$ref": "#/components/schemas/SupportAuthor"
                },
                "body": {
                  "type": "string",
                  "nullable": true
                },
                "created_at": {
                  "type": "string",
                  "format": "date-time"
                }
              }
            }
          },
          "known_entities": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["kind", "value"],
              "properties": {
                "kind": {
                  "$ref": "#/components/schemas/SupportTokenKind"
                },
                "value": {
                  "type": "string"
                },
                "ref": {
                  "type": "string",
                  "nullable": true
                },
                "label": {
                  "type": "string",
                  "nullable": true
                }
              }
            }
          },
          "case": {
            "type": "object",
            "properties": {
              "status": {
                "$ref": "#/components/schemas/SupportCaseStatus"
              },
              "type": {
                "$ref": "#/components/schemas/SupportCaseType"
              },
              "flags": {
                "$ref": "#/components/schemas/SupportCaseFlags"
              },
              "failed_turns": {
                "type": "integer"
              }
            }
          },
          "ai": {
            "type": "object",
            "required": ["enabled"],
            "properties": {
              "enabled": {
                "type": "boolean"
              },
              "off_reason": {
                "type": "string",
                "nullable": true,
                "enum": [
                  "feature_off",
                  "policy_kill",
                  "locale_not_evaluated",
                  "cap_reached",
                  "circuit_open",
                  "with_person",
                  null
                ]
              },
              "templates_only": {
                "type": "boolean",
                "description": "Production without a ZDR model endpoint, or in model mode a language not listed in SUPPORT_AI_EVALUATED_LOCALES (ARCH-029a \u00a72.1, \u00a72.3, amendment 2026-10-02): the turn runs the rules, the local moderation guard and help-article template answers, and MUST NOT call any model. off_reason locale_not_evaluated is no longer sent."
              },
              "models": {
                "type": "object",
                "properties": {
                  "chat": {
                    "type": "string"
                  },
                  "utility": {
                    "type": "string"
                  },
                  "moderation": {
                    "type": "string"
                  }
                }
              },
              "prompt_version": {
                "type": "string"
              },
              "neutral_sentence": {
                "type": "string"
              },
              "extra_triggers": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "locale": {
                      "type": "string"
                    },
                    "phrase": {
                      "type": "string"
                    }
                  }
                }
              },
              "max_tool_calls": {
                "type": "integer",
                "enum": [4]
              },
              "policy": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/AiTurnPolicy"
                  }
                ],
                "description": "The tenant's effective AI policy (ARCH-029a \u00a711.5, DEC-0034). Absent: a finance-api before it; the workflows use the code defaults."
              }
            }
          },
          "client_actions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportActionKind"
            }
          },
          "availability": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportAvailabilityInternal"
              }
            ],
            "description": "0.26.0: whether a person of l1 can join now. The AI never says a person is joining while staffed_now is false; template answers append hours_line when it is not null."
          },
          "tokens": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "token": {
                  "$ref": "#/components/schemas/SupportToken"
                },
                "kind": {
                  "$ref": "#/components/schemas/SupportTokenKind"
                }
              }
            }
          },
          "brand": {
            "type": "string",
            "nullable": true,
            "description": "0.26.2: the tenant's brand (branding.bank_name, else branding.name, else the tenant's name). The presence sentence names it, never \"the bank\"; finance-api accepts a presence answer only with this brand."
          }
        }
      },
      "SupportTokeniseRequest": {
        "type": "object",
        "required": ["conversation_id", "entries"],
        "properties": {
          "conversation_id": {
            "type": "string",
            "format": "uuid"
          },
          "entries": {
            "type": "array",
            "minItems": 1,
            "maxItems": 200,
            "items": {
              "type": "object",
              "required": ["kind", "value"],
              "properties": {
                "kind": {
                  "$ref": "#/components/schemas/SupportTokenKind"
                },
                "value": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 256
                },
                "ref": {
                  "type": "string",
                  "nullable": true,
                  "description": "Entity id (card, account, transfer)."
                },
                "label": {
                  "type": "string",
                  "nullable": true,
                  "description": "Display text for CARD, ACCOUNT and TX tokens."
                }
              }
            }
          }
        }
      },
      "SupportTokeniseResult": {
        "type": "object",
        "required": ["tokens", "map_size"],
        "properties": {
          "tokens": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["index", "token", "kind", "new"],
              "properties": {
                "index": {
                  "type": "integer"
                },
                "token": {
                  "$ref": "#/components/schemas/SupportToken"
                },
                "kind": {
                  "$ref": "#/components/schemas/SupportTokenKind"
                },
                "new": {
                  "type": "boolean"
                }
              }
            }
          },
          "map_size": {
            "type": "integer",
            "maximum": 2000
          }
        }
      },
      "SupportTokenList": {
        "type": "object",
        "required": ["tokens"],
        "properties": {
          "tokens": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "token": {
                  "$ref": "#/components/schemas/SupportToken"
                },
                "kind": {
                  "$ref": "#/components/schemas/SupportTokenKind"
                }
              }
            }
          }
        }
      },
      "SupportTraceInput": {
        "type": "object",
        "required": [
          "conversation_id",
          "turn_id",
          "kind",
          "seq",
          "payload_tokenised"
        ],
        "properties": {
          "conversation_id": {
            "type": "string",
            "format": "uuid"
          },
          "turn_id": {
            "type": "string",
            "format": "uuid"
          },
          "kind": {
            "$ref": "#/components/schemas/SupportTraceKind"
          },
          "seq": {
            "type": "integer",
            "minimum": 0
          },
          "payload_tokenised": {
            "description": "Tokenised payload, at most 256 KB.",
            "oneOf": [
              {
                "type": "object"
              },
              {
                "type": "string"
              }
            ]
          },
          "model": {
            "type": "string",
            "nullable": true
          },
          "prompt_version": {
            "type": "string",
            "nullable": true
          },
          "prompt_hash": {
            "type": "string",
            "nullable": true,
            "pattern": "^[0-9a-f]{64}$",
            "description": "SHA-256 of the workflows' prompt templates; with it the stored\n`prompt_version` is `<version>.<first 12 characters>`.\n"
          },
          "policy_version": {
            "type": "integer",
            "nullable": true,
            "description": "`ai.policy.version` of the turn (ARCH-029a \u00a711.5); with `policy_hash` stored as `<version>.<first 12 hex>`."
          },
          "policy_hash": {
            "type": "string",
            "nullable": true,
            "pattern": "^[0-9a-f]{64}$",
            "description": "`ai.policy.hash` of the turn."
          },
          "latency_ms": {
            "type": "integer",
            "nullable": true
          },
          "tokens_in": {
            "type": "integer",
            "nullable": true
          },
          "tokens_out": {
            "type": "integer",
            "nullable": true
          }
        }
      },
      "SupportTraceCreated": {
        "type": "object",
        "required": ["trace_id", "sha256"],
        "properties": {
          "trace_id": {
            "type": "string",
            "format": "uuid"
          },
          "sha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          }
        }
      },
      "SupportTrace": {
        "allOf": [
          {
            "$ref": "#/components/schemas/SupportTraceInput"
          },
          {
            "$ref": "#/components/schemas/SupportTraceCreated"
          },
          {
            "type": "object",
            "properties": {
              "created_at": {
                "type": "string",
                "format": "date-time"
              }
            }
          }
        ]
      },
      "SupportToolCallRequest": {
        "type": "object",
        "required": ["conversation_id", "turn_id", "call_id", "args"],
        "properties": {
          "conversation_id": {
            "type": "string",
            "format": "uuid"
          },
          "turn_id": {
            "type": "string",
            "format": "uuid"
          },
          "call_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "args": {
            "type": "object",
            "description": "The tool's input (ARCH-029a \u00a711.3, SupportTool*Input schemas)."
          }
        }
      },
      "SupportToolResult": {
        "type": "object",
        "required": [
          "call_id",
          "tool",
          "result",
          "error",
          "truncated",
          "trace_id"
        ],
        "properties": {
          "call_id": {
            "type": "string"
          },
          "tool": {
            "type": "string",
            "enum": [
              "account_balances",
              "spending_summary",
              "recent_transactions",
              "transaction_detail",
              "card_status",
              "fees_explained",
              "statement_link",
              "search_help"
            ]
          },
          "result": {
            "type": "object",
            "nullable": true,
            "description": "Tokenised, at most 8 KB (SupportTool*Output schemas)."
          },
          "error": {
            "type": "string",
            "nullable": true,
            "enum": ["not_found", "unavailable", "invalid_arguments", null]
          },
          "truncated": {
            "type": "boolean"
          },
          "trace_id": {
            "type": "string",
            "format": "uuid"
          }
        }
      },
      "SupportModelCitation": {
        "type": "object",
        "required": ["source"],
        "properties": {
          "source": {
            "type": "string",
            "enum": ["tool", "help_article"]
          },
          "call_id": {
            "type": "string",
            "maxLength": 64
          },
          "article_id": {
            "type": "string",
            "format": "uuid"
          }
        }
      },
      "SupportModelAction": {
        "type": "object",
        "required": ["kind", "params"],
        "description": "Model params are tokenised: open_card_freeze `card` ([CARD_n]);\nopen_statement `account` ([ACCOUNT_n]), `period`; open_transaction\n`tx_ref` ([TX_n]); open_send `amount_minor`, `currency`;\nopen_insights `section`, `month`.\n",
        "properties": {
          "kind": {
            "$ref": "#/components/schemas/SupportActionKind"
          },
          "params": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "SupportModelReply": {
        "type": "object",
        "description": "What the model must return (JSON mode, ARCH-029a \u00a711.1). An answer needs at least one citation.",
        "required": ["kind", "body", "citations", "actions"],
        "properties": {
          "kind": {
            "$ref": "#/components/schemas/SupportReplyKind"
          },
          "body": {
            "type": "string",
            "minLength": 1,
            "maxLength": 1500
          },
          "citations": {
            "type": "array",
            "maxItems": 6,
            "items": {
              "$ref": "#/components/schemas/SupportModelCitation"
            }
          },
          "actions": {
            "type": "array",
            "maxItems": 3,
            "items": {
              "$ref": "#/components/schemas/SupportModelAction"
            }
          }
        }
      },
      "SupportAiMessageInput": {
        "type": "object",
        "required": [
          "conversation_id",
          "turn_id",
          "reply",
          "generated_by",
          "prompt_version",
          "trace_ids",
          "moderation"
        ],
        "properties": {
          "conversation_id": {
            "type": "string",
            "format": "uuid"
          },
          "turn_id": {
            "type": "string",
            "format": "uuid"
          },
          "reply": {
            "type": "object",
            "required": ["kind", "body_tokenised", "citations", "actions"],
            "properties": {
              "kind": {
                "$ref": "#/components/schemas/SupportReplyKind"
              },
              "body_tokenised": {
                "type": "string",
                "minLength": 1,
                "maxLength": 1500
              },
              "refusal_reason": {
                "type": "string",
                "nullable": true,
                "enum": [
                  "out_of_scope",
                  "other_person",
                  "advice_not_offered",
                  "action_not_allowed",
                  "generic"
                ],
                "description": "Refusals only (absent: `generic`). The body must be the\nfixed sentence of this reason in one of en, es, de, pt, ar,\nca (ARCH-029a \u00a711.1a). A refusal's actions are dropped.\n"
              },
              "presence": {
                "type": "boolean",
                "nullable": true,
                "description": "Clarify only: the answer to \"is anyone there?\". The body\nmust be the fixed presence sentence of ARCH-029a \u00a711.1a,\nwith at most the tenant's current hours line; actions are\ndropped.\n"
              },
              "citations": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/SupportModelCitation"
                }
              },
              "actions": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/SupportModelAction"
                }
              }
            }
          },
          "generated_by": {
            "$ref": "#/components/schemas/SupportGeneratedBy"
          },
          "model": {
            "type": "string",
            "nullable": true
          },
          "prompt_version": {
            "type": "string",
            "pattern": "^[A-Za-z0-9._-]{1,64}$",
            "description": "The workflows' prompt version (ARCH-029a \u00a77.5)."
          },
          "prompt_hash": {
            "type": "string",
            "nullable": true,
            "pattern": "^[0-9a-f]{64}$",
            "description": "SHA-256 of the workflows' prompt templates."
          },
          "policy_version": {
            "type": "integer",
            "nullable": true,
            "description": "`ai.policy.version` of the turn (ARCH-029a \u00a711.5). With\n`policy_hash`: when either differs from the tenant's effective\npolicy now, 409 `policy_changed` (the workflows hand off). Absent:\na workflows build before P1. The message stores the current\npolicy as `<version>.<first 12 hex>` either way. An action the\npolicy does not list is 422 `action_not_allowed`; while a kill\nswitch is set 409 `policy_kill`; a model answer in a language\noutside the policy's `locales` 409 `templates_only`; an `answer`\nto a turn whose customer messages name a blocked topic 422\n`blocked_topic`; a version above 999999999 422 `invalid_field`.\n"
          },
          "policy_hash": {
            "type": "string",
            "nullable": true,
            "pattern": "^[0-9a-f]{64}$"
          },
          "trace_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          },
          "moderation": {
            "type": "object",
            "required": ["input", "output"],
            "properties": {
              "input": {
                "type": "string",
                "enum": ["pass"]
              },
              "output": {
                "type": "string",
                "enum": ["pass"]
              }
            }
          }
        }
      },
      "SupportAiMessageCreated": {
        "type": "object",
        "required": ["message_id", "created_at"],
        "properties": {
          "message_id": {
            "type": "string",
            "format": "uuid"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SupportInternalHandoffInput": {
        "type": "object",
        "required": [
          "conversation_id",
          "turn_id",
          "trigger",
          "reason",
          "language"
        ],
        "properties": {
          "conversation_id": {
            "type": "string",
            "format": "uuid"
          },
          "turn_id": {
            "type": "string",
            "format": "uuid"
          },
          "trigger": {
            "type": "string",
            "enum": ["rule", "model", "system"]
          },
          "reason": {
            "$ref": "#/components/schemas/SupportHandoffReason"
          },
          "rule_id": {
            "type": "string",
            "nullable": true,
            "example": "es.complaint.v1"
          },
          "intent": {
            "type": "string",
            "nullable": true
          },
          "language": {
            "type": "string"
          },
          "summary_tokenised": {
            "type": "string",
            "maxLength": 600,
            "nullable": true
          },
          "facts_used": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          },
          "complaint_message_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "Required when reason is complaint."
          },
          "flags": {
            "type": "object",
            "properties": {
              "vulnerability": {
                "type": "boolean"
              }
            }
          },
          "neutral_reply": {
            "type": "boolean",
            "default": false,
            "description": "restricted_topic; finance-api writes the tenant's neutral sentence as an AI template message."
          },
          "chip_message_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "0.28.1: the pending customer message of this conversation whose chip made this a rule handoff; finance-api applies that message's chip, context and client actions (the `unrecognised` safe steps and queue). Not a pending customer message of the conversation: 422 `invalid_field`. Absent: the chip rule `chip.unrecognised.v1` reads the turn's own message."
          }
        }
      },
      "SupportInternalHandoffResult": {
        "type": "object",
        "required": [
          "case_id",
          "case_ref",
          "queue_label",
          "expected_reply",
          "expected_response_text",
          "system_message_id",
          "ai_message_id",
          "availability"
        ],
        "properties": {
          "case_id": {
            "type": "string",
            "format": "uuid"
          },
          "case_ref": {
            "type": "string"
          },
          "queue_label": {
            "type": "string",
            "description": "Customer-safe label, the same for every queue."
          },
          "expected_reply": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportExpectedReply"
              }
            ],
            "nullable": true
          },
          "expected_response_text": {
            "type": "string",
            "description": "Staffed: \"A person from AIRIS support will reply, usually within 4 hours.\"\nClosed: \"No one from our team can join right now. We're available Mon\u2013Fri 09:00\u201318:00 (Madrid time). We'll reply when we're back; you don't need to write again.\"\nOpen, nobody available (or show_availability off): \"No one from our team can join right now. We'll reply as soon as someone is free; you don't need to write again.\"\nIn en, es, de, pt, ar (0.26.0).\n"
          },
          "system_message_id": {
            "type": "string",
            "format": "uuid"
          },
          "ai_message_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "availability": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportAvailabilityInternal"
              }
            ],
            "description": "The snapshot written to the handoff_requested message (0.26.0)."
          }
        }
      },
      "SupportTimerFired": {
        "type": "object",
        "required": ["case_id", "kind", "epoch", "due_at"],
        "properties": {
          "case_id": {
            "type": "string",
            "format": "uuid"
          },
          "kind": {
            "$ref": "#/components/schemas/SupportTimerKind"
          },
          "epoch": {
            "type": "integer",
            "minimum": 0
          },
          "due_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SupportTimerResult": {
        "type": "object",
        "required": ["applied"],
        "properties": {
          "applied": {
            "type": "boolean"
          },
          "reason": {
            "type": "string",
            "enum": ["stale_epoch", "case_closed", "already_met"],
            "nullable": true
          }
        }
      },
      "SupportReconcileResult": {
        "type": "object",
        "required": [
          "tenants",
          "cases_checked",
          "timers_rearmed",
          "breaches_marked"
        ],
        "properties": {
          "tenants": {
            "type": "integer"
          },
          "cases_checked": {
            "type": "integer"
          },
          "timers_rearmed": {
            "type": "integer"
          },
          "breaches_marked": {
            "type": "integer"
          },
          "letters_issued": {
            "type": "integer",
            "description": "Pending complaint withdrawal letters issued."
          },
          "letters_failed": {
            "type": "integer",
            "description": "Pending complaint withdrawal letters still pending after this run."
          }
        }
      },
      "SupportRetentionRequest": {
        "type": "object",
        "properties": {
          "dry_run": {
            "type": "boolean",
            "default": false
          }
        }
      },
      "SupportRetentionResult": {
        "type": "object",
        "required": ["tenants"],
        "properties": {
          "tenants": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "tenant_id": {
                  "type": "string"
                },
                "cases_anonymised": {
                  "type": "integer"
                },
                "complaints_skipped": {
                  "type": "integer"
                },
                "traces_deleted": {
                  "type": "integer"
                },
                "token_maps_deleted": {
                  "type": "integer"
                }
              }
            }
          },
          "documents": {
            "type": "array",
            "description": "Per tenant (SF-tickets-document-retention, ARCH-030 \u00a714):\nretain_until set or extended on CDD copies and letters of\nclosed customers, copies and letters deleted after it (rows\nkept), cdd tickets anonymised, unregistered KYC copies of\nrolled-back accepts deleted.\n",
            "items": {
              "type": "object",
              "properties": {
                "tenant_id": {
                  "type": "string"
                },
                "cdd_documents_retained": {
                  "type": "integer"
                },
                "letters_retained": {
                  "type": "integer"
                },
                "cdd_documents_deleted": {
                  "type": "integer"
                },
                "letters_deleted": {
                  "type": "integer"
                },
                "cdd_tickets_anonymised": {
                  "type": "integer"
                },
                "kyc_orphans_deleted": {
                  "type": "integer"
                },
                "letters_failed": {
                  "type": "integer",
                  "description": "Letters whose Object Lock could not be extended (skipped, next run)."
                }
              }
            }
          }
        }
      },
      "SupportNotifyKind": {
        "type": "string",
        "description": "SupportNotify handlers (ARCH-029a \u00a710.3, ARCH-030 \u00a710.3).",
        "enum": [
          "agent_replied",
          "complaint_acknowledged",
          "final_reply_sent",
          "sla_alert",
          "ticket_opened",
          "ticket_updated",
          "request_reminder",
          "request_not_accepted",
          "ticket_resolved",
          "letter_issued",
          "complaint_withdrawn",
          "staff_watch"
        ]
      },
      "SupportNotifyContext": {
        "type": "object",
        "description": "No message text, amount or case type, ever.",
        "required": ["skip", "kind"],
        "properties": {
          "skip": {
            "type": "boolean",
            "description": "The customer read the thread (or the ticket) past the event, or the feature is off; staff kinds: no recipient."
          },
          "kind": {
            "$ref": "#/components/schemas/SupportNotifyKind"
          },
          "customer_id": {
            "type": "string",
            "nullable": true
          },
          "recipient_email": {
            "type": "string",
            "nullable": true
          },
          "locale": {
            "type": "string",
            "nullable": true
          },
          "brand_name": {
            "type": "string",
            "nullable": true
          },
          "app_link": {
            "type": "string",
            "nullable": true,
            "example": "fernel://support?customer_id=c-123"
          },
          "portal_link": {
            "type": "string",
            "nullable": true
          },
          "complaint": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportComplaintAck"
              }
            ],
            "nullable": true
          },
          "recipients": {
            "type": "array",
            "description": "sla_alert and staff_watch only.",
            "items": {
              "type": "object",
              "properties": {
                "email": {
                  "type": "string"
                },
                "locale": {
                  "type": "string"
                }
              }
            }
          },
          "case_reference": {
            "type": "string",
            "nullable": true
          },
          "timer_kind": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SupportTimerKind"
              }
            ],
            "nullable": true
          },
          "due_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "activity_kind": {
            "type": "string",
            "nullable": true,
            "description": "staff_watch only (ARCH-030 \u00a72 activity_kind).",
            "enum": [
              "message",
              "note",
              "request",
              "submission",
              "review",
              "file",
              "status",
              "assignment",
              "transfer",
              "watcher",
              "link",
              "letter",
              "complaint",
              "sla",
              "task"
            ]
          }
        }
      },
      "SupportToolSpendingSummaryInput": {
        "type": "object",
        "additionalProperties": false,
        "required": ["period"],
        "properties": {
          "period": {
            "type": "string",
            "pattern": "^([0-9]{4}-(0[1-9]|1[0-2])|last_30_days|last_90_days)$"
          },
          "category": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]{1,39}$"
          }
        }
      },
      "SupportToolSpendingSummaryOutput": {
        "type": "object",
        "required": [
          "currency",
          "period",
          "out_minor",
          "in_minor",
          "by_category",
          "top_merchants"
        ],
        "properties": {
          "currency": {
            "type": "string"
          },
          "period": {
            "type": "string"
          },
          "out_minor": {
            "type": "integer",
            "format": "int64"
          },
          "in_minor": {
            "type": "integer",
            "format": "int64"
          },
          "by_category": {
            "type": "array",
            "maxItems": 12,
            "items": {
              "type": "object",
              "properties": {
                "category": {
                  "type": "string"
                },
                "amount_minor": {
                  "type": "integer",
                  "format": "int64"
                },
                "count": {
                  "type": "integer"
                }
              }
            }
          },
          "top_merchants": {
            "type": "array",
            "maxItems": 5,
            "items": {
              "type": "object",
              "properties": {
                "merchant": {
                  "type": "string",
                  "description": "Company name in clear or a [PERSON_n] token."
                },
                "amount_minor": {
                  "type": "integer",
                  "format": "int64"
                },
                "count": {
                  "type": "integer"
                }
              }
            }
          },
          "other_currencies": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "SupportToolRecentTransactionsInput": {
        "type": "object",
        "additionalProperties": false,
        "required": ["filter", "limit"],
        "properties": {
          "filter": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "direction": {
                "type": "string",
                "enum": ["in", "out"]
              },
              "category": {
                "type": "string",
                "pattern": "^[a-z][a-z0-9_]{1,39}$"
              },
              "merchant": {
                "type": "string",
                "minLength": 2,
                "maxLength": 100
              },
              "counterparty": {
                "type": "string",
                "pattern": "^\\[PERSON_[1-9][0-9]{0,4}\\]$"
              },
              "amount_min_minor": {
                "type": "integer",
                "minimum": 0
              },
              "amount_max_minor": {
                "type": "integer",
                "minimum": 0
              },
              "from": {
                "type": "string",
                "format": "date"
              },
              "to": {
                "type": "string",
                "format": "date"
              }
            }
          },
          "limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 20
          }
        }
      },
      "SupportToolTransactionRow": {
        "type": "object",
        "required": [
          "tx_ref",
          "booked_at",
          "amount_minor",
          "currency",
          "direction",
          "category",
          "merchant",
          "status",
          "rail"
        ],
        "properties": {
          "tx_ref": {
            "type": "string",
            "pattern": "^\\[TX_[1-9][0-9]{0,4}\\]$"
          },
          "booked_at": {
            "type": "string",
            "format": "date-time"
          },
          "amount_minor": {
            "type": "integer",
            "format": "int64",
            "description": "Negative for money out."
          },
          "currency": {
            "type": "string"
          },
          "direction": {
            "type": "string",
            "enum": ["in", "out"]
          },
          "category": {
            "type": "string"
          },
          "mcc": {
            "type": "string",
            "nullable": true
          },
          "merchant": {
            "type": "string",
            "nullable": true,
            "description": "Company name in clear or a [PERSON_n] token."
          },
          "status": {
            "type": "string"
          },
          "rail": {
            "type": "string"
          }
        }
      },
      "SupportToolRecentTransactionsOutput": {
        "type": "object",
        "required": ["items", "has_more"],
        "properties": {
          "items": {
            "type": "array",
            "maxItems": 20,
            "items": {
              "$ref": "#/components/schemas/SupportToolTransactionRow"
            }
          },
          "has_more": {
            "type": "boolean"
          }
        }
      },
      "SupportToolTransactionDetailInput": {
        "type": "object",
        "additionalProperties": false,
        "required": ["tx_ref"],
        "properties": {
          "tx_ref": {
            "type": "string",
            "pattern": "^\\[TX_[1-9][0-9]{0,4}\\]$"
          }
        }
      },
      "SupportToolTransactionDetailOutput": {
        "allOf": [
          {
            "$ref": "#/components/schemas/SupportToolTransactionRow"
          },
          {
            "type": "object",
            "required": ["timeline", "fees", "remittance", "references"],
            "properties": {
              "timeline": {
                "type": "object",
                "description": "DEC-0030 \u00a71 (outcome, expected_by, steps).",
                "properties": {
                  "outcome": {
                    "type": "string"
                  },
                  "expected_by": {
                    "type": "string",
                    "format": "date-time",
                    "nullable": true
                  },
                  "steps": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/TimelineStep"
                    }
                  }
                }
              },
              "fees": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string"
                    },
                    "amount_minor": {
                      "type": "integer",
                      "format": "int64"
                    }
                  }
                }
              },
              "remittance": {
                "type": "string",
                "nullable": true,
                "description": "Untrusted text, quoted and tokenised."
              },
              "references": {
                "type": "object",
                "properties": {
                  "uetr": {
                    "type": "string",
                    "nullable": true
                  },
                  "end_to_end_id": {
                    "type": "string",
                    "nullable": true
                  }
                }
              }
            }
          }
        ]
      },
      "SupportToolAccountBalancesInput": {
        "type": "object",
        "description": "0.26.2. No argument: the accounts are the conversation's customer's, never an argument.",
        "additionalProperties": false,
        "properties": {}
      },
      "SupportToolAccountBalancesOutput": {
        "type": "object",
        "required": ["as_of", "month", "accounts", "totals"],
        "properties": {
          "as_of": {
            "type": "string",
            "format": "date"
          },
          "month": {
            "type": "string",
            "pattern": "^[0-9]{4}-(0[1-9]|1[0-2])$"
          },
          "accounts": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "account",
                "currency",
                "available_minor",
                "booked_minor"
              ],
              "properties": {
                "account": {
                  "type": "string",
                  "pattern": "^\\[ACCOUNT_[1-9][0-9]{0,4}\\]$"
                },
                "type": {
                  "type": "string",
                  "nullable": true
                },
                "currency": {
                  "type": "string",
                  "minLength": 3,
                  "maxLength": 3
                },
                "available_minor": {
                  "type": "integer",
                  "nullable": true
                },
                "booked_minor": {
                  "type": "integer",
                  "nullable": true
                },
                "pending_out_minor": {
                  "type": "integer",
                  "nullable": true
                },
                "month_in_minor": {
                  "type": "integer",
                  "nullable": true
                },
                "month_out_minor": {
                  "type": "integer",
                  "nullable": true
                }
              }
            }
          },
          "totals": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["currency", "available_minor", "booked_minor"],
              "properties": {
                "currency": {
                  "type": "string"
                },
                "available_minor": {
                  "type": "integer"
                },
                "booked_minor": {
                  "type": "integer"
                }
              }
            }
          }
        }
      },
      "SupportToolCardStatusInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {}
      },
      "SupportToolCardStatusOutput": {
        "type": "object",
        "required": ["cards"],
        "properties": {
          "cards": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["card", "type", "status", "declines_7d"],
              "properties": {
                "card": {
                  "type": "string",
                  "pattern": "^\\[CARD_[1-9][0-9]{0,4}\\]$"
                },
                "type": {
                  "type": "string",
                  "enum": ["virtual", "physical"]
                },
                "status": {
                  "type": "string",
                  "enum": ["active", "frozen", "blocked", "expired"]
                },
                "declines_7d": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            }
          }
        }
      },
      "SupportToolFeesExplainedInput": {
        "type": "object",
        "additionalProperties": false,
        "description": "Exactly one of tx_ref or fee_type.",
        "oneOf": [
          {
            "required": ["tx_ref"]
          },
          {
            "required": ["fee_type"]
          }
        ],
        "properties": {
          "tx_ref": {
            "type": "string",
            "pattern": "^\\[TX_[1-9][0-9]{0,4}\\]$"
          },
          "fee_type": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]{1,39}$"
          }
        }
      },
      "SupportToolFeesExplainedOutput": {
        "type": "object",
        "required": [
          "fee_type",
          "amount_minor",
          "currency",
          "schedule",
          "rule_text"
        ],
        "properties": {
          "fee_type": {
            "type": "string"
          },
          "amount_minor": {
            "type": "integer",
            "format": "int64"
          },
          "currency": {
            "type": "string"
          },
          "schedule": {
            "type": "string"
          },
          "rule_text": {
            "type": "string"
          }
        }
      },
      "SupportToolStatementLinkInput": {
        "type": "object",
        "additionalProperties": false,
        "required": ["account", "period"],
        "properties": {
          "account": {
            "type": "string",
            "pattern": "^\\[ACCOUNT_[1-9][0-9]{0,4}\\]$"
          },
          "period": {
            "type": "string",
            "pattern": "^[0-9]{4}-(0[1-9]|1[0-2])$"
          }
        }
      },
      "SupportToolStatementLinkOutput": {
        "type": "object",
        "required": ["available", "action"],
        "description": "Never a URL; the client downloads with its own session (DEC-0030 \u00a73).",
        "properties": {
          "available": {
            "type": "boolean"
          },
          "action": {
            "type": "object",
            "nullable": true,
            "properties": {
              "kind": {
                "type": "string",
                "enum": ["open_statement"]
              },
              "params": {
                "type": "object",
                "properties": {
                  "account": {
                    "type": "string"
                  },
                  "period": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      },
      "SupportToolSearchHelpInput": {
        "type": "object",
        "additionalProperties": false,
        "required": ["query", "locale"],
        "properties": {
          "query": {
            "type": "string",
            "minLength": 2,
            "maxLength": 200
          },
          "locale": {
            "$ref": "#/components/schemas/SupportLocale"
          }
        }
      },
      "SupportToolSearchHelpOutput": {
        "type": "object",
        "required": ["articles"],
        "properties": {
          "articles": {
            "type": "array",
            "maxItems": 3,
            "items": {
              "type": "object",
              "required": ["article_id", "title", "snippet", "path"],
              "properties": {
                "article_id": {
                  "type": "string",
                  "format": "uuid"
                },
                "title": {
                  "type": "string"
                },
                "snippet": {
                  "type": "string"
                },
                "path": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "SupportToolHandoffInput": {
        "type": "object",
        "additionalProperties": false,
        "required": ["reason", "summary"],
        "properties": {
          "reason": {
            "type": "string",
            "enum": [
              "customer_request",
              "low_confidence",
              "out_of_scope",
              "repeated_failure",
              "complaint",
              "other"
            ]
          },
          "summary": {
            "type": "string",
            "minLength": 1,
            "maxLength": 600
          }
        }
      },
      "SupportToolHandoffOutput": {
        "type": "object",
        "required": ["case_ref", "queue_label", "expected_response_text"],
        "properties": {
          "case_ref": {
            "type": "string"
          },
          "queue_label": {
            "type": "string"
          },
          "expected_response_text": {
            "type": "string"
          }
        }
      }
    },
    "responses": {
      "DocumentBadRequest": {
        "description": "`invalid_id` (malformed path id) or `invalid_filter` (a malformed or\nrepeated parameter, a format that needs exactly one `account_id`,\na summary `interval` other than `week`, or a history filter the\nexport refuses).\n",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/DocumentError"
            },
            "example": {
              "error": {
                "code": "invalid_filter",
                "message": "This format needs exactly one account_id"
              }
            }
          }
        }
      },
      "DocumentNotFound": {
        "description": "The customer, account or transfer does not exist for the caller.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/DocumentError"
            }
          }
        }
      },
      "DocumentUnprocessable": {
        "description": "`invalid_period` (missing or malformed dates, `from` after `to`,\n`to` in the future, more than 366 days, more than 13 ISO weeks with\n`interval=week`), `unsupported_format`\n(`xlsx` or unknown) or `too_many_rows` (more than 20 000 rows:\nchoose a shorter period).\n",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/DocumentError"
            },
            "example": {
              "error": {
                "code": "invalid_period",
                "message": "The period is longer than 366 days"
              }
            }
          }
        }
      },
      "DocumentBusy": {
        "description": "`busy`: two documents of this customer are being generated; retry after `Retry-After`. A service-key call counts for its `X-Customer-ID`; without one, all such calls share one limit.",
        "headers": {
          "Retry-After": {
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/DocumentError"
            }
          }
        }
      },
      "DocumentUnavailable": {
        "description": "`documents_unavailable`: the database or, for statement balances, the ledger could not be read; retry after `Retry-After`.",
        "headers": {
          "Retry-After": {
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/DocumentError"
            }
          }
        }
      },
      "DocumentFailed": {
        "description": "`documents_failed`: the document could not be generated.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/DocumentError"
            }
          }
        }
      },
      "HistoryBadRequest": {
        "description": "`invalid_cursor`, `invalid_limit`, `invalid_filter` (a malformed\nfilter, a filter the endpoint does not take, or a non-repeatable\nfilter given twice) or `invalid_id` (malformed path id).\n",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/HistoryError"
            },
            "example": {
              "error": "invalid_cursor",
              "message": "cursor was issued for other filters"
            }
          }
        }
      },
      "HistoryUnavailable": {
        "description": "`history_unavailable`: the database could not be reached or the\nquery timed out or waited for a lock. Retry after `Retry-After`\nseconds. Never answered as an empty list.\n",
        "headers": {
          "Retry-After": {
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/HistoryError"
            }
          }
        }
      },
      "HistorySearchTooBroad": {
        "description": "`search_too_broad`: a `q` search hit its 3 s statement timeout.\nRetrying the same search does not help: narrow it (more text, a date\nrange, an account). No `Retry-After`.\n",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/HistoryError"
            }
          }
        }
      },
      "HistorySearchBusy": {
        "description": "`search_busy`: this customer already has 2 searches running. Retry\nafter `Retry-After` seconds.\n",
        "headers": {
          "Retry-After": {
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/HistoryError"
            }
          }
        }
      },
      "HistoryFailed": {
        "description": "`history_failed`: the history could not be read.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/HistoryError"
            }
          }
        }
      },
      "BadRequest": {
        "description": "Bad request",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Authentication required",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Forbidden": {
        "description": "Not the caller's resource (`forbidden`)",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "StaffForbiddenRole": {
        "description": "`forbidden_role`: the staff route gate (DEC-0043) refused the admin\nsession's role for this route and method, before any handler and\nwith nothing changed. See \"Staff Access\" in the introduction.\n",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": "forbidden_role",
                "message": "This role may not use this route"
              }
            }
          }
        }
      },
      "CheckerMustBeBankOfficer": {
        "description": "`checker_must_be_bank_officer`: the platform `super_admin` may ask\nfor a four-eyes change on a bank's behalf but never decides it; an\nofficer of that bank does. Nothing changed. See \"Platform assist\" in\nthe introduction.\n",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": "checker_must_be_bank_officer",
                "message": "An officer of the bank decides this request, not the platform"
              }
            }
          }
        }
      },
      "PlatformAssistRefused": {
        "description": "A platform `super_admin` change on a bank's behalf without its bank\n(`tenant_required`) or its reason (`reason_required`, 10 to 1000\ncharacters in `X-Change-Reason` or `?reason=`). Nothing changed. See\n\"Platform assist\" in the introduction.\n",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": "reason_required",
                "message": "Give the reason for this change on the bank's behalf (10 to 1000 characters)"
              }
            }
          }
        }
      },
      "NotFound": {
        "description": "Resource not found",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Conflict": {
        "description": "State conflict (e.g. modifying terminated entity)",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "BeneficiaryBadRequest": {
        "description": "Validation failed. `invalid_id` (malformed UUID), `invalid_expected_accounts`\n(DELETE /payees/{payeeId}: a malformed `expected_accounts` or another query key), `invalid_type`,\n`invalid_iban` (mod-97), `invalid_contact_id`, `name_required`,\n`account_required` (neither IBAN nor account plus routing).\n",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/BeneficiaryError"
            },
            "example": {
              "error": "invalid_iban"
            }
          }
        }
      },
      "BeneficiaryForbidden": {
        "description": "`forbidden`: customer JWT asked for another customer, a tenant-wide\nlist, verification, or sent a foreign customer_id/tenant_id.\n`forbidden_role`: write with a role other than owner, admin or customer.\n`read_only_session`: write during an admin impersonation session.\n",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/BeneficiaryError"
            },
            "example": {
              "error": "forbidden"
            }
          }
        }
      },
      "BeneficiaryNotFound": {
        "description": "Payee does not exist or belongs to another customer.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/BeneficiaryError"
            },
            "example": {
              "error": "not_found"
            }
          }
        }
      },
      "PayeeLastAccount": {
        "description": "The payee's last account cannot be removed; delete the payee instead.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/BeneficiaryError"
            },
            "example": {
              "error": "last_account"
            }
          }
        }
      },
      "PayeeChanged": {
        "description": "The payee's accounts do not give the guard in `expected_accounts` (an account was linked or removed since the customer confirmed). Nothing was deleted; read the payee again and confirm the new list.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/BeneficiaryError"
            },
            "example": {
              "error": "payee_changed"
            }
          }
        }
      },
      "BeneficiaryDuplicate": {
        "description": "Same customer already has an active payee with this IBAN or account plus routing number.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/BeneficiaryError"
            },
            "example": {
              "error": "beneficiary_duplicate"
            }
          }
        }
      },
      "SupportNotModified": {
        "description": "`If-None-Match` matched: nothing changed. No body.",
        "headers": {
          "ETag": {
            "$ref": "#/components/headers/SupportETag"
          }
        }
      },
      "SupportBadRequest": {
        "description": "`invalid_json`, `invalid_id`, `invalid_cursor`, `invalid_limit` or `invalid_filter`.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/SupportError"
            }
          }
        }
      },
      "SupportUnauthorized": {
        "description": "`unauthorized`: no or an invalid token.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/SupportError"
            }
          }
        }
      },
      "SupportForbidden": {
        "description": "`customer_jwt_required`, `staff_session_required`,\n`service_key_required`, `forbidden` (tenant mismatch),\n`forbidden_role`, `read_only_session` (impersonation write) or\n`not_assignee`.\n",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/SupportError"
            },
            "example": {
              "error": {
                "code": "read_only_session",
                "message": "An impersonation session cannot write"
              }
            }
          }
        }
      },
      "SupportNotFound": {
        "description": "`not_found`; on customer routes also `support_disabled` (the tenant\nfeature `support_chat` is off: use the support e-mail) and, on\n`/support/tickets*` and `/support/uploads*`, `tickets_disabled`\n(the tenant feature `support_tickets` is off).\n",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/SupportError"
            }
          }
        }
      },
      "SupportConflict": {
        "description": "`idempotency_key_reused`, `request_in_progress` (with\n`Retry-After`), `invalid_transition` (with `allowed`),\n`complaint_final_reply_required`, `already_assigned`,\n`not_resolved`, `already_rated`, `already_final`, `turn_done`,\n`tool_budget_exhausted`, `trace_conflict`, `templates_only`, and on\nthe thread routes (0.33.0) `thread_closed`, `too_many_open_chats`\nand `confirm_required`, as the route says.\n",
        "headers": {
          "Retry-After": {
            "$ref": "#/components/headers/SupportRetryAfter"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/SupportError"
            }
          }
        }
      },
      "SupportUnprocessable": {
        "description": "Validation failed: `blank`, `too_long` (with `limit`),\n`invalid_characters`, `invalid_field` (with `field`) and the\nroute's own codes.\n",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/SupportError"
            }
          }
        }
      },
      "SupportRateLimited": {
        "description": "`rate_limited`: retry after `Retry-After` seconds (ARCH-029a \u00a70.8).",
        "headers": {
          "Retry-After": {
            "$ref": "#/components/headers/SupportRetryAfter"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/SupportError"
            }
          }
        }
      },
      "SupportUnavailable": {
        "description": "`support_unavailable`: the database or a dependency could not be reached; nothing was written. Retry after `Retry-After`.",
        "headers": {
          "Retry-After": {
            "$ref": "#/components/headers/SupportRetryAfter"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/SupportError"
            }
          }
        }
      }
    },
    "headers": {
      "SupportETag": {
        "description": "Weak ETag (`W/\"<16 hex>\"`) of the answer (ARCH-029a \u00a70.7).",
        "schema": {
          "type": "string",
          "example": "W/\"9f2c4e1a7b3d5c60\""
        }
      },
      "SupportRetryAfter": {
        "description": "Seconds to wait before retrying.",
        "schema": {
          "type": "integer",
          "minimum": 1
        }
      }
    }
  }
}
