{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/if/json-schema/if-client-list-response-schema.json",
  "title": "ClientListResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/if-clients-api-openapi.yml#/components/schemas/ClientListResponse",
  "required": [
    "connect",
    "data",
    "metadata",
    "workflow"
  ],
  "type": "object",
  "properties": {
    "workflow": {
      "$ref": "#/$defs/ClientListWorkflowContainer"
    },
    "data": {
      "$ref": "#/$defs/ClientListDataContainer"
    },
    "connect": {
      "$ref": "#/$defs/ClientListConnectContainer"
    },
    "metadata": {
      "$ref": "#/$defs/ClientListMetadataContainer"
    }
  },
  "$defs": {
    "Address": {
      "required": [
        "city",
        "country",
        "street"
      ],
      "type": "object",
      "properties": {
        "country": {
          "maxLength": 2,
          "minLength": 2,
          "pattern": "^[A-Z]{2}$",
          "type": "string"
        },
        "region": {
          "type": "string"
        },
        "postalCode": {
          "type": "string"
        },
        "city": {
          "type": "string"
        },
        "street": {
          "type": "string"
        },
        "houseNumber": {
          "type": "string"
        },
        "refinement": {
          "type": "string"
        }
      },
      "description": "residential address object for individual clients"
    },
    "AttributeMap": {
      "type": "object"
    },
    "Client": {
      "required": [
        "clientNumber",
        "id",
        "identity",
        "status"
      ],
      "type": "object",
      "properties": {
        "attributes": {
          "$ref": "#/$defs/AttributeMap"
        },
        "id": {
          "type": "string",
          "description": "client id",
          "format": "uuid",
          "readOnly": true
        },
        "clientNumber": {
          "maxLength": 8,
          "minLength": 8,
          "pattern": "^d{8}$",
          "type": "string",
          "description": "user friendly client identifier",
          "readOnly": true
        },
        "status": {
          "$ref": "#/$defs/ClientStatus"
        },
        "identity": {
          "type": "object",
          "description": "client identity object",
          "oneOf": [
            {
              "$ref": "#/$defs/LegalEntityIdentityCorporate"
            },
            {
              "$ref": "#/$defs/LegalEntityIdentityIndividual"
            }
          ]
        },
        "profile": {
          "type": "object",
          "description": "client profile object",
          "oneOf": [
            {
              "$ref": "#/$defs/ClientProfileCorporate"
            },
            {
              "$ref": "#/$defs/ClientProfileIndividual"
            }
          ]
        },
        "relations": {
          "type": "array",
          "description": "client related legal entities",
          "items": {
            "$ref": "#/$defs/ClientRelation"
          }
        },
        "risk": {
          "$ref": "#/$defs/ClientRisk"
        }
      }
    },
    "ClientListConnectContainer": {
      "type": "object"
    },
    "ClientListDataContainer": {
      "required": [
        "clients"
      ],
      "type": "object",
      "properties": {
        "client": {
          "$ref": "#/$defs/ClientResourceListQueryInput"
        },
        "clients": {
          "type": "array",
          "description": "collection of clients",
          "readOnly": true,
          "items": {
            "$ref": "#/$defs/Client"
          }
        }
      }
    },
    "ClientListMetadataContainer": {
      "required": [
        "page"
      ],
      "type": "object",
      "properties": {
        "page": {
          "$ref": "#/$defs/PageMetadata"
        }
      }
    },
    "ClientListWorkflowContainer": {
      "type": "object"
    },
    "ClientProfile": {
      "required": [
        "identityType"
      ],
      "type": "object",
      "properties": {
        "identityType": {
          "type": "string"
        }
      }
    },
    "ClientProfileCorporate": {
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/ClientProfile"
        },
        {
          "type": "object",
          "properties": {
            "identityType": {
              "$ref": "#/$defs/LegalEntityType"
            },
            "phone": {
              "type": "string",
              "description": "client contact phone number"
            },
            "email": {
              "type": "string",
              "description": "client contact email"
            },
            "registrationAddress": {
              "$ref": "#/$defs/Address"
            }
          }
        }
      ]
    },
    "ClientProfileIndividual": {
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/ClientProfile"
        },
        {
          "type": "object",
          "properties": {
            "identityType": {
              "$ref": "#/$defs/LegalEntityType"
            },
            "phone": {
              "type": "string",
              "description": "client contact phone number"
            },
            "email": {
              "type": "string",
              "description": "client contact email"
            },
            "residentialAddress": {
              "$ref": "#/$defs/Address"
            }
          }
        }
      ]
    },
    "ClientRelatedLegalEntityRelation": {
      "type": "string",
      "description": "relation of legal entity with client",
      "enum": [
        "director",
        "shareholder",
        "director-and-shareholder",
        "authorized-person"
      ]
    },
    "ClientRelation": {
      "required": [
        "clientId",
        "id",
        "identity",
        "relation"
      ],
      "type": "object",
      "properties": {
        "attributes": {
          "$ref": "#/$defs/AttributeMap"
        },
        "id": {
          "type": "string",
          "description": "client relation id",
          "format": "uuid",
          "readOnly": true
        },
        "clientId": {
          "type": "string",
          "description": "id of client",
          "format": "uuid",
          "readOnly": true
        },
        "relation": {
          "$ref": "#/$defs/ClientRelatedLegalEntityRelation"
        },
        "identity": {
          "type": "object",
          "description": "client relation identity object",
          "oneOf": [
            {
              "$ref": "#/$defs/LegalEntityIdentityCorporate"
            },
            {
              "$ref": "#/$defs/LegalEntityIdentityIndividual"
            }
          ]
        },
        "percentageOfOwnership": {
          "type": "number",
          "description": "percentage of ownership"
        },
        "profile": {
          "type": "object",
          "description": "client relation profile object",
          "oneOf": [
            {
              "$ref": "#/$defs/ClientProfileCorporate"
            },
            {
              "$ref": "#/$defs/ClientProfileIndividual"
            }
          ]
        }
      },
      "description": "client relation data model"
    },
    "ClientResourceListQueryInput": {
      "type": "object",
      "properties": {
        "identityType": {
          "$ref": "#/$defs/LegalEntityType"
        },
        "fullName": {
          "type": "string"
        },
        "status": {
          "$ref": "#/$defs/ClientStatus"
        },
        "clientNumber": {
          "type": "string"
        },
        "risk": {
          "$ref": "#/$defs/ClientRisk"
        }
      },
      "writeOnly": true
    },
    "ClientRisk": {
      "type": "string",
      "description": "client risk level",
      "enum": [
        "low",
        "medium",
        "high",
        "severe"
      ]
    },
    "ClientStatus": {
      "type": "string",
      "description": "status of the client",
      "readOnly": true,
      "enum": [
        "active",
        "inactive"
      ]
    },
    "CorporationType": {
      "type": "string",
      "enum": [
        "ltd",
        "plc",
        "llp",
        "lp",
        "gp",
        "st",
        "other"
      ]
    },
    "LegalEntityIdentification": {
      "type": "object",
      "properties": {
        "type": {
          "$ref": "#/$defs/LegalEntityIdentificationType"
        },
        "identificationNumber": {
          "type": "string"
        },
        "issuingCountry": {
          "maxLength": 2,
          "minLength": 2,
          "pattern": "^[A-Z]{2}$",
          "type": "string"
        },
        "issueDate": {
          "type": "string",
          "format": "date"
        },
        "expirationDate": {
          "type": "string",
          "format": "date"
        }
      }
    },
    "LegalEntityIdentificationType": {
      "type": "string",
      "enum": [
        "registration-number",
        "passport",
        "identity-card",
        "driving-licence",
        "foreign-identity-card",
        "tax-number"
      ]
    },
    "LegalEntityIdentity": {
      "required": [
        "type"
      ],
      "type": "object",
      "properties": {
        "type": {
          "type": "string"
        }
      }
    },
    "LegalEntityIdentityCorporate": {
      "required": [
        "legalName"
      ],
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/LegalEntityIdentity"
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "$ref": "#/$defs/LegalEntityType"
            },
            "country": {
              "maxLength": 2,
              "minLength": 2,
              "pattern": "^[A-Z]{2}$",
              "type": "string"
            },
            "identifications": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/LegalEntityIdentification"
              }
            },
            "legalName": {
              "type": "string"
            },
            "incorporationDate": {
              "type": "string",
              "format": "date"
            },
            "corporationType": {
              "$ref": "#/$defs/CorporationType"
            }
          }
        }
      ]
    },
    "LegalEntityIdentityIndividual": {
      "required": [
        "familyName",
        "givenName"
      ],
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/LegalEntityIdentity"
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "$ref": "#/$defs/LegalEntityType"
            },
            "country": {
              "maxLength": 2,
              "minLength": 2,
              "pattern": "^[A-Z]{2}$",
              "type": "string"
            },
            "identifications": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/LegalEntityIdentification"
              }
            },
            "givenName": {
              "type": "string"
            },
            "familyName": {
              "type": "string"
            },
            "birthDate": {
              "type": "string",
              "format": "date"
            }
          }
        }
      ]
    },
    "LegalEntityType": {
      "type": "string",
      "enum": [
        "corporate",
        "individual"
      ]
    },
    "PageMetadata": {
      "required": [
        "number",
        "size",
        "totalElements",
        "totalPages"
      ],
      "type": "object",
      "properties": {
        "size": {
          "minimum": 0,
          "type": "integer",
          "description": "number of elements in this page",
          "format": "int32"
        },
        "number": {
          "minimum": 0,
          "type": "integer",
          "description": "index of page starting from 0",
          "format": "int32"
        },
        "totalElements": {
          "minimum": 0,
          "type": "integer",
          "description": "total number of elements in all of the pages",
          "format": "int64",
          "readOnly": true
        },
        "totalPages": {
          "minimum": 0,
          "type": "integer",
          "description": "number of total pages",
          "format": "int32",
          "readOnly": true
        }
      }
    }
  }
}