{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "urn:sbv:iso20022:pacs.009.001.09",
  "title": "FinancialInstitutionCreditTransfer — pacs.009.001.09 (SBV profile)",
  "description": "ISO 20022 pacs.009.001.09: Chuyển vốn liên ngân hàng — kết nối ASEAN mBridge",
  "type": "object",
  "required": ["Document"],
  "properties": {
    "Document": {
      "type": "object",
      "required": ["FinInstnCdtTrf"],
      "properties": {
        "FinInstnCdtTrf": {
          "type": "object",
          "required": ["GrpHdr", "CdtTrfTxInf"],
          "properties": {

            "GrpHdr": {
              "type": "object",
              "required": ["MsgId", "CreDtTm", "NbOfTxs", "SttlmInf"],
              "properties": {
                "MsgId":   { "type": "string", "maxLength": 35 },
                "CreDtTm": { "type": "string", "format": "date-time" },
                "NbOfTxs": { "type": "string", "pattern": "^[0-9]{1,15}$" },
                "SttlmInf": {
                  "type": "object",
                  "required": ["SttlmMtd"],
                  "properties": {
                    "SttlmMtd": { "type": "string", "enum": ["INDA","INGA","COVE","CLRG"] },
                    "ClrSys":   { "type": "object", "properties": { "Cd": { "type": "string", "enum": ["MBRIDGE","SWIFT","VNIBPS"] } } }
                  }
                }
              }
            },

            "CdtTrfTxInf": {
              "type": "array",
              "minItems": 1,
              "items": {
                "type": "object",
                "required": ["PmtId", "IntrBkSttlmAmt", "Cdtr", "CdtrAgt"],
                "properties": {
                  "PmtId": {
                    "type": "object",
                    "required": ["EndToEndId", "UETR"],
                    "properties": {
                      "InstrId":    { "type": "string", "maxLength": 35 },
                      "EndToEndId": { "type": "string", "maxLength": 35 },
                      "UETR":       { "type": "string", "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$" }
                    }
                  },
                  "IntrBkSttlmAmt": {
                    "type": "object",
                    "required": ["_", "$"],
                    "properties": {
                      "_": { "type": "string" },
                      "$": { "type": "object", "required": ["Ccy"], "properties": { "Ccy": { "type": "string", "pattern": "^[A-Z]{3}$" } } }
                    }
                  },
                  "Purp":    { "type": "object", "properties": { "Cd": { "type": "string", "maxLength": 4 } } },
                  "InstrAgt": { "type": "object", "properties": { "FinInstnId": { "type": "object", "properties": { "BICFI": { "type": "string" }, "LEI": { "type": "string" } } } } },
                  "Dbtr":    { "type": "object", "properties": { "FinInstnId": { "type": "object", "properties": { "BICFI": { "type": "string" }, "LEI": { "type": "string" } } } } },
                  "DbtrAgt": { "type": "object", "properties": { "FinInstnId": { "type": "object", "properties": { "BICFI": { "type": "string" } } } } },
                  "Cdtr":    { "type": "object", "required": ["FinInstnId"], "properties": { "FinInstnId": { "type": "object", "required": ["BICFI"], "properties": { "BICFI": { "type": "string" }, "LEI": { "type": "string" } } } } },
                  "CdtrAgt": { "type": "object", "required": ["FinInstnId"], "properties": { "FinInstnId": { "type": "object", "required": ["BICFI"], "properties": { "BICFI": { "type": "string" } } } } },
                  "UndrlygCstmrCdtTrf": {
                    "type": "object",
                    "description": "Dữ liệu KH gốc (cross-border — bắt buộc với mBridge)",
                    "properties": {
                      "Dbtr":     { "type": "object", "properties": { "Nm": { "type": "string", "maxLength": 140 } } },
                      "DbtrAcct": { "type": "object", "properties": { "Id": { "type": "object", "properties": { "Othr": { "type": "object" } } } } },
                      "Cdtr":     { "type": "object", "properties": { "Nm": { "type": "string", "maxLength": 140 } } },
                      "CdtrAcct": { "type": "object", "properties": { "Id": { "type": "object", "properties": { "Othr": { "type": "object" } } } } },
                      "RmtInf":   { "type": "object", "properties": { "Ustrd": { "type": "string", "maxLength": 140 } } }
                    }
                  }
                }
              }
            }

          }
        }
      }
    }
  }
}
