{
  "definitions": {
    "YYYYMMDDType": {
      "type": "number",
      "minimum": 10000000,
      "maximum": 99999999
    },
    "unsigned": {
      "type": "number",
      "multipleOf": 1,
      "minimum": 0,
      "maximum": 9223372036854775807
    },
    "largeTraderIdType": {
      "type": "string",
      "maxLength": 13,
      "examples": [
        "ULT00001-0001",
        "12345678-9012"
      ],
      "pattern": "[0-9]{8}-[0-9]{4}|ULT[0-9A-Z]{5}-[0-9A-Z]{4}"
    },
    "firmDesignatedIdType": {
      "type": "string",
      "maxLength": 40,
      "examples": [
        "EZAccount123"
      ],
      "pattern": "^((?![|\"@,])[\\x20-\\x7E]){1,40}$"
    }
  },
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "required": [
    "version",
    "catReporterCRD",
    "catSubmitterID",
    "fdidRecordCount"
  ],
  "additionalProperties": false,
  "properties": {
    "version": {
      "type": "string",
      "maxLength": 10,
      "enum": [
        "1.0.0"
      ],
      "description": "The version of the CAIS Schema under which the data is reported. Initial version utilized will be 1.0.0"
    },
    "catReporterCRD": {
      "$ref": "#/definitions/unsigned",
      "description": "The CRD number assigned to the firm to which the data within the file belongs."
    },
    "catSubmitterID": {
      "$ref": "#/definitions/unsigned",
      "description": "The ID of the CAT Reporting Agent that submitted the file to CAT. In the case the CAT Reporter is submitting data for themselves, they must still populate the CAT Submitter ID field."
    },
    "fdidRecordCount": {
      "$ref": "#/definitions/unsigned",
      "description": "The count of firmDesignatedID attribute occurrences within the file. Used to validate the count of FDID records intended to be submitted within the file matches the count of records present in the file."
    },
    "fdidRecordList": {
      "type": "array",
      "items": {
        "type": "object",
        "description": "Structure for the array of FDID Records that are included in the file. Required if the submission file contains one or more FDID records; not required if no FDID records are included in the file",
        "required": [
          "fdidRecordID",
          "firmDesignatedID",
          "fdidType",
          "fdidDate"
        ],
        "dependencies": {
          "fdidEndDate": ["fdidEndReason"],
          "fdidEndReason": ["fdidEndDate"],
          "fdidEndDateNULL": ["fdidEndReasonNULL", "replacedByFDIDNULL"],
          "fdidEndReasonNULL": ["fdidEndDateNULL", "replacedByFDIDNULL"]
        },
        "additionalProperties": false,
        "properties": {
          "fdidRecordID": {
            "$ref": "#/definitions/unsigned",
            "description": "A unique reference to a single FDID for a single submission file."
          },
          "firmDesignatedID": {
            "$ref": "#/definitions/firmDesignatedIdType",
            "description": "The Firm Designated ID of the Account or Relationship being reported by the CAT Reporting firm"
          },
          "fdidType": {
            "type": "string",
            "enum": [
              "ACCOUNT",
              "RELATIONSHIP",
              "ENTITYID"
            ],
            "description": "Representation of the type of record of the reported FDID. Values: ACCOUNT – Account type record, RELATIONSHIP – Relationship type record, ENTITYID - Entity ID type record",
            "examples": [
              "ACCOUNT"
            ]
          },
          "fdidDate": {
            "$ref": "#/definitions/YYYYMMDDType",
            "description": "Date on which the FDID account opened, as defined in Section 2.2.3 of this specification, in YYYYMMDD format"
          },
          "fdidEndDate": {
            "$ref": "#/definitions/YYYYMMDDType",
            "description": "Date on which the Account was closed or the Relationship was ended, in YYYYMMDD format. Must be provided if the fdidEndReason field is populated."
          },
          "fdidEndDateNULL": {
            "type": "boolean",
            "description": "Indicates any fdidEndDate currently stored in CAT CAIS should be cleared. Must be provided as true if fdidEndReasonNULL is populated as true. Must not be provided as true if fdidEndDate is populated."
          },
          "fdidEndReason": {
            "type": "string",
            "enum": [
              "CORRECTION",
              "ENDED",
              "REPLACED",
              "OTHER"
            ],
            "description": "Reason why the Account was closed or the Relationship was ended. Must be provided if the fdidEndDate field is populated. Must not be provided if fdidEndReasonNULL is populated as true. Values: CORRECTION – FDID was erroneously reported ENDED – FDID was ended REPLACED – FDID replaced by another FDID within the CAT Reporter Firm. OTHER – Other unlisted reason for ending the FDID"
          },
          "fdidEndReasonNULL": {
            "type": "boolean",
            "description": "Indicates any fdidEndReason currently stored in CAT CAIS should be cleared. Must be provided as true if fdidEndDateNULL is populated as true. Must not be provided as true if fdidEndReason is populated."
          },
          "replacedByFDID": {
            "$ref": "#/definitions/firmDesignatedIdType",
            "description": "The new FDID replacing the currently reported FDID, used to provide historical linkage across replaced records over time. Must be provided if the fdidEndReason is REPLACED. Must not be provided if the fdidEndReason is any value other than REPLACED. Must not be provided if replacedByFDIDNULL is populated as true."
          },
          "replacedByFDIDNULL": {
            "type": "boolean",
            "description": "Indicates any replacedByFDID currently stored in CAT CAIS should be cleared. Must not be provided if replacedByFDID is populated"
          },
          "largeTraderList": {
            "type": "array",
            "items": {
              "type": "object",
              "description": "Structure for the array of LTID records that are associated to the FDID record within the file. Required if the submission file contains one or more LTID records associated to the FDID record; not required if no LTID records are included in the file in association to the reported FDID.",
              "required": [
                "largeTraderRecordID",
                "largeTraderID",
                "ltidEffectiveDate"
              ],
              "dependencies": {
                "ltidEndDate": ["ltidEndReason"],
                "ltidEndReason": ["ltidEndDate"],
                "ltidEndDateNULL": ["ltidEndReasonNULL"],
                "ltidEndReasonNULL": ["ltidEndDateNULL"]
              },
              "additionalProperties": false,
              "properties": {
                "largeTraderRecordID": {
                  "$ref": "#/definitions/unsigned",
                  "description": "A unique reference to a single LTID in reference to a single FDID for a single submission file."
                },
                "largeTraderID": {
                  "$ref": "#/definitions/largeTraderIdType",
                  "description": "The LTID or ULTID associated to the FDID in the CAT Reporter’s system."
                },
                "ltidEffectiveDate": {
                  "$ref": "#/definitions/YYYYMMDDType",
                  "description": "Date on which the LTID became associated to the FDID within the CAT Reporter’s system, in YYYYMMDD format."
                },
                "ltidEndDate": {
                  "$ref": "#/definitions/YYYYMMDDType",
                  "description": "Date on which the LTID or ULTID was no longer associated to the FDID within the CAT Reporter’s system, in YYYYMMDD format. Must be provided if the ltidEndReason field is populated. Must not be provided if ltidEndDateNULL is populated as true."
                },
                "ltidEndDateNULL": {
                  "type": "boolean",
                  "description": "Indicated any ltidEndDate currently stored in CAT CAIS shoud be cleared. Must be provided if ltidEndReasonNULL is populated. Must not be provided if ltidEndDate is populated."
                },
                "ltidEndReason": {
                  "type": "string",
                  "enum": [
                    "CORRECTION",
                    "ENDED",
                    "REPLACED",
                    "OTHER"
                  ],
                  "description": "Reason why the LTID or ULTID was no longer associated to the FDID. Must be populated in order to end date an LTID-to-FDID association in the system. Must be provided if the ltidEndDate field is populated. Must not be provided if ltidEndReasonNULL is populated as true. Values: CORRECTION – LTID was erroneously reported ENDED – LTID-to-FDID association was ended REPLACED – LTID was replaced by a different LTID OTHER – Other unlisted reason for ending the LTID-to-FDID association"
                },
                "ltidEndReasonNULL": {
                  "type": "boolean",
                  "description": "Indicated any ltidEndReason currently stired in CAT CAIS should be cleared. Must be provided if ltidEndDateNULL is populated. Must not be provided if ltidEndReason is populated."
                }
              }
            }
          }
        }
      }
    },
    "correctionList": {
      "type": "array",
      "items": {
        "type": "object",
        "description": "Structure for the array of Correction records within the file. Required if the submission file contains one or more Correction records.",
        "required": [
          "rejectionID",
          "correctionAction"
        ],
        "additionalProperties": false,
        "properties": {
          "rejectionID": {
            "$ref": "#/definitions/unsigned",
            "description": "The rejectionID from a prior submission that was created for the particular Data Ingestion error being corrected."
          },
          "correctionAction": {
            "type": "string",
            "enum": [
              "CORRECTION",
              "DELETE"
            ],
            "description": "The particular action that is being taken to correct for the prior rejection. Values: CORRECTION – A new entry is included in the submission file to correct for the prior rejected record using a new firmDesignatedID or new largeTraderID., DELETE – The prior rejection needs to be cleared without a new record being submitted.",
            "examples": [
              "CORRECTION"
            ]
          },
          "correctingFirmDesignatedID": {
            "$ref": "#/definitions/firmDesignatedIdType",
            "description": "The firmDesignatedID within the submission file that is correcting for the prior rejected FDID. Required if the correctionAction is CORRECTION.",
           }
        }
      }
    }
  }
}
