{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.montran.com/schemas/financial-institution.json",
  "title": "Montran Financial Institution",
  "description": "A financial institution participating in payment processing through Montran's infrastructure. Used to identify banks, clearing members, and financial intermediaries in payment transactions, aligned with ISO 20022 financial institution identification structures.",
  "type": "object",
  "required": [
    "bic"
  ],
  "properties": {
    "bic": {
      "type": "string",
      "description": "Bank Identifier Code (SWIFT/BIC) - ISO 9362",
      "pattern": "^[A-Z]{4}[A-Z]{2}[A-Z0-9]{2}([A-Z0-9]{3})?$"
    },
    "name": {
      "type": "string",
      "description": "Full legal name of the financial institution"
    },
    "lei": {
      "type": "string",
      "description": "Legal Entity Identifier (ISO 17442)",
      "pattern": "^[A-Z0-9]{20}$"
    },
    "clearingSystemMemberId": {
      "type": "string",
      "description": "Clearing system member identification (e.g., ABA routing number, sort code)"
    },
    "clearingSystem": {
      "type": "string",
      "description": "Clearing system in which the institution is a member"
    },
    "country": {
      "type": "string",
      "description": "Country of registration (ISO 3166-1 alpha-2)",
      "pattern": "^[A-Z]{2}$"
    },
    "address": {
      "type": "object",
      "description": "Postal address of the institution",
      "properties": {
        "streetName": {
          "type": "string"
        },
        "buildingNumber": {
          "type": "string"
        },
        "postCode": {
          "type": "string"
        },
        "townName": {
          "type": "string"
        },
        "country": {
          "type": "string",
          "pattern": "^[A-Z]{2}$"
        }
      }
    },
    "connectedClearingSystems": {
      "type": "array",
      "description": "Clearing and settlement systems the institution connects to via Montran",
      "items": {
        "type": "string",
        "enum": [
          "SEPA",
          "TARGET2",
          "FEDWIRE",
          "CHIPS",
          "CHAPS",
          "FASTER_PAYMENTS",
          "TIPS",
          "RT1",
          "RTGS",
          "ACH",
          "SWIFT"
        ]
      }
    },
    "supportedMessageFormats": {
      "type": "array",
      "description": "Message formats supported by the institution",
      "items": {
        "type": "string",
        "enum": [
          "SWIFT_FIN",
          "ISO20022",
          "ISO8583",
          "NACHA",
          "PROPRIETARY"
        ]
      }
    }
  }
}
