{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/financekey/json-schema/financekey-finance-key-entity-credit-facility-pkg-credit-facility-schema.json",
  "title": "FinanceKey.Entity.CreditFacilityPkg.CreditFacility",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/financekey-credit-facilities-api-openapi.yml#/components/schemas/FinanceKey.Entity.CreditFacilityPkg.CreditFacility",
  "required": [
    "amount",
    "creditFacilityStateId",
    "creditFacilityTypeId",
    "currencyId",
    "referenceNumber"
  ],
  "type": "object",
  "properties": {
    "createdById": {
      "type": [
        "integer",
        "null"
      ],
      "description": "The identity of the account that created the initial record.",
      "format": "int32",
      "readOnly": true
    },
    "createdOn": {
      "type": "string",
      "description": "The date and time the record was initially created.",
      "format": "date-time",
      "readOnly": true
    },
    "updatedById": {
      "type": [
        "integer",
        "null"
      ],
      "description": "The identity of the account that last modified the record.",
      "format": "int32",
      "readOnly": true
    },
    "updateOn": {
      "type": "string",
      "description": "The date and time the record was last modified.",
      "format": "date-time",
      "readOnly": true
    },
    "closedById": {
      "type": [
        "integer",
        "null"
      ],
      "description": "The identity of the account that deactivated and closed the record.",
      "format": "int32",
      "readOnly": true
    },
    "closedOn": {
      "type": "string",
      "description": "The date and time the record is to be considered as inactive and closed.",
      "format": "date-time",
      "readOnly": true
    },
    "active": {
      "type": "boolean",
      "description": "A flag that shows if the record is currently active. This values is calculated based on the current date and the record closed date.",
      "readOnly": true
    },
    "rowVersion": {
      "type": [
        "string",
        "null"
      ],
      "description": "A unique version stamp of the record.",
      "format": "byte",
      "readOnly": true
    },
    "sessionId": {
      "type": [
        "string",
        "null"
      ],
      "description": "The identity of the session that last modified the record.",
      "readOnly": true
    },
    "creditFacilityId": {
      "type": "integer",
      "description": "CreditFacilityId is an integer data field located in the CreditFacility table. It is used to uniquely identify and store credit facilities associated with particular customers.",
      "format": "int32",
      "readOnly": true
    },
    "referenceNumber": {
      "maxLength": 64,
      "minLength": 1,
      "type": "string",
      "description": "A Unique reference number for the credit facility"
    },
    "creditFacilityTypeId": {
      "maxLength": 64,
      "minLength": 1,
      "type": "string",
      "description": "The type of credit facility"
    },
    "creditFacilityStateId": {
      "maxLength": 64,
      "minLength": 1,
      "type": "string",
      "description": "The current state of the Credit Facility"
    },
    "debtorId": {
      "type": "integer",
      "description": "The legal entity that will be the holder of the credit facility. For overdrafts, this is the beneficiary of the account.",
      "format": "int32"
    },
    "lenderId": {
      "type": "integer",
      "description": "The provider of the credit facility. For overdrafts, this will be the institute that provides the bank account.",
      "format": "int32"
    },
    "currencyId": {
      "maxLength": 128,
      "minLength": 1,
      "type": "string",
      "description": "The currency of the credit facility"
    },
    "accountId": {
      "type": [
        "integer",
        "null"
      ],
      "description": "The AccountId field in the CreditFacility table is an integer data type used to uniquely identify each account in the facility. This field is a required field and must be a unique integer that remains constant for each associated record.",
      "format": "int32"
    },
    "amount": {
      "type": "number",
      "description": "The amount of the credit facility",
      "format": "double"
    },
    "effectiveDate": {
      "type": [
        "string",
        "null"
      ],
      "description": "The EffectiveDate field in the CreditFacility table includes the date when the credit facility is entered into by the customer and is effective for the duration of the agreement. It is a datetime2 data type and stores both the date and time data values.",
      "format": "date-time"
    },
    "comment": {
      "type": [
        "string",
        "null"
      ],
      "description": "Miscellaneous notes and information for the entry or record."
    },
    "includeCreditBalances": {
      "type": "boolean",
      "description": "When the credit facility is applied to a cash pool or bank cash pool, and this box is checked, credit balances will be taken into account and result in a net reduction of the facility usage. Default behaviour is for credit facilities to only consider overdrawn balances for facility usage."
    },
    "rate": {
      "type": [
        "number",
        "null"
      ],
      "format": "double"
    },
    "referenceRateId": {
      "maxLength": 64,
      "type": [
        "string",
        "null"
      ]
    }
  },
  "additionalProperties": false
}