{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/if/json-schema/if-client-create-response-schema.json",
  "title": "ClientCreateResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/if-clients-api-openapi.yml#/components/schemas/ClientCreateResponse",
  "required": [
    "connect",
    "data",
    "metadata",
    "workflow"
  ],
  "type": "object",
  "properties": {
    "workflow": {
      "$ref": "#/$defs/ClientCreateWorkflowContainer"
    },
    "data": {
      "$ref": "#/$defs/ClientCreateDataContainer"
    },
    "connect": {
      "$ref": "#/$defs/ClientCreateConnectContainer"
    },
    "metadata": {
      "$ref": "#/$defs/PlatformAPIMetadataContainer"
    }
  },
  "$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"
    },
    "BankingUserProfile": {
      "type": "object",
      "properties": {
        "phone": {
          "type": "string"
        },
        "residentialAddress": {
          "$ref": "#/$defs/Address"
        }
      }
    },
    "BankingUserStatus": {
      "type": "string",
      "readOnly": true,
      "enum": [
        "active",
        "inactive"
      ]
    },
    "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"
        }
      }
    },
    "ClientCreateConnect": {
      "type": "string",
      "description": "connection source type",
      "enum": [
        "explicit"
      ]
    },
    "ClientCreateConnectContainer": {
      "type": "object",
      "properties": {
        "type": {
          "$ref": "#/$defs/ClientCreateConnect"
        },
        "serviceProvider": {
          "type": "string",
          "description": "service provider that will be used to source the client data"
        }
      }
    },
    "ClientCreateDataContainer": {
      "type": "object",
      "properties": {
        "client": {
          "$ref": "#/$defs/Client"
        },
        "sourceId": {
          "type": "string",
          "description": "id of the client to be migrated, required if workflow is migration",
          "writeOnly": true
        },
        "user": {
          "$ref": "#/$defs/User"
        },
        "userClientRelations": {
          "type": "array",
          "description": "automatically created user client resource. Convenient for individual clients",
          "readOnly": true,
          "items": {
            "$ref": "#/$defs/UserClientRelation"
          }
        }
      }
    },
    "ClientCreateWorkflow": {
      "type": "string",
      "description": "unique workflow code",
      "enum": [
        "direct",
        "migration"
      ]
    },
    "ClientCreateWorkflowContainer": {
      "required": [
        "code"
      ],
      "type": "object",
      "properties": {
        "code": {
          "$ref": "#/$defs/ClientCreateWorkflow"
        },
        "createUser": {
          "type": "boolean",
          "description": "create a user related with the client"
        }
      }
    },
    "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"
    },
    "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"
      ]
    },
    "PlatformAPIMetadataContainer": {
      "type": "object"
    },
    "User": {
      "required": [
        "category",
        "email",
        "identity",
        "type"
      ],
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid",
          "readOnly": true
        },
        "email": {
          "type": "string"
        },
        "givenName": {
          "type": "string"
        },
        "familyName": {
          "type": "string"
        },
        "identity": {
          "$ref": "#/$defs/UserIdentityResource"
        },
        "category": {
          "type": "string",
          "readOnly": true,
          "enum": [
            "external"
          ]
        },
        "type": {
          "type": "string",
          "readOnly": true,
          "enum": [
            "human"
          ]
        },
        "profile": {
          "$ref": "#/$defs/BankingUserProfile"
        },
        "status": {
          "$ref": "#/$defs/BankingUserStatus"
        }
      },
      "description": "automatically created user resource. Convenient for individual clients",
      "readOnly": true
    },
    "UserClientRelation": {
      "required": [
        "clientId"
      ],
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid",
          "readOnly": true
        },
        "userId": {
          "type": "string",
          "format": "uuid",
          "readOnly": true
        },
        "clientId": {
          "type": "string",
          "format": "uuid"
        },
        "status": {
          "$ref": "#/$defs/UserClientStatus"
        }
      },
      "description": "automatically created user client resource. Convenient for individual clients",
      "readOnly": true
    },
    "UserClientStatus": {
      "type": "string",
      "readOnly": true,
      "enum": [
        "allowed",
        "revoked"
      ]
    },
    "UserIdentityResource": {
      "required": [
        "familyName",
        "givenName",
        "type"
      ],
      "type": "object",
      "properties": {
        "type": {
          "$ref": "#/$defs/LegalEntityType"
        },
        "givenName": {
          "type": "string",
          "description": "user given name"
        },
        "familyName": {
          "type": "string",
          "description": "user family name"
        },
        "birthDate": {
          "type": "string",
          "description": "user birthdate",
          "format": "date"
        }
      },
      "description": "user identity information"
    }
  }
}