{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/if/json-schema/if-beneficiary-create-request-schema.json",
  "title": "BeneficiaryCreateRequest",
  "description": "request model",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/if-beneficiaries-api-openapi.yml#/components/schemas/BeneficiaryCreateRequest",
  "required": [
    "connect",
    "data",
    "metadata",
    "workflow"
  ],
  "type": "object",
  "properties": {
    "workflow": {
      "$ref": "#/$defs/BeneficiaryCreateWorkflowContainer"
    },
    "data": {
      "$ref": "#/$defs/BeneficiaryCreateRequestDataContainer"
    },
    "connect": {
      "$ref": "#/$defs/AccountCreateConnectContainer"
    },
    "metadata": {
      "$ref": "#/$defs/BeneficiaryCreateMetadataContainer"
    }
  },
  "$defs": {
    "AccountCreateConnectContainer": {
      "required": [
        "serviceProvider",
        "type"
      ],
      "type": "object",
      "properties": {
        "type": {
          "$ref": "#/$defs/BeneficiaryCreateConnect"
        },
        "serviceProvider": {
          "type": "string",
          "description": "account is connected to this service provider "
        }
      },
      "description": "connect container"
    },
    "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"
        }
      }
    },
    "Beneficiary": {
      "required": [
        "clientId",
        "identity"
      ],
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "clientId": {
          "type": "string",
          "description": "ID of client in UUID format",
          "format": "uuid"
        },
        "identity": {
          "$ref": "#/$defs/LegalEntityIdentity"
        },
        "contact": {
          "$ref": "#/$defs/BeneficiaryContact"
        },
        "address": {
          "$ref": "#/$defs/Address"
        },
        "title": {
          "type": "string"
        },
        "fullName": {
          "type": "string"
        },
        "bankAccounts": {
          "type": "array",
          "description": "beneficiary bank accounts",
          "readOnly": true,
          "items": {
            "$ref": "#/$defs/BeneficiaryBankAccount"
          }
        }
      },
      "description": "Beneficiary Resource Object"
    },
    "BeneficiaryBankAccount": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "accountHolderType": {
          "$ref": "#/$defs/LegalEntityType"
        },
        "beneficiaryId": {
          "type": "string",
          "format": "uuid"
        },
        "country": {
          "type": "string"
        },
        "currency": {
          "type": "string"
        },
        "routingCodes": {
          "$ref": "#/$defs/RoutingCodeMap"
        },
        "accountNumber": {
          "type": "string"
        },
        "iban": {
          "type": "string"
        },
        "bankName": {
          "type": "string"
        },
        "creationDateTime": {
          "type": "string",
          "format": "date-time"
        },
        "creatingUserUsername": {
          "type": "string"
        },
        "oneTimePasswordId": {
          "type": "string",
          "format": "uuid"
        },
        "oneTimePassword": {
          "type": "string"
        },
        "ledgerNumber": {
          "type": "string"
        }
      },
      "description": "Beneficiary Bank Account Resource Object",
      "readOnly": true
    },
    "BeneficiaryContact": {
      "type": "object",
      "properties": {
        "phone": {
          "type": "string",
          "description": "beneficiary contact phone number"
        },
        "email": {
          "type": "string",
          "description": "beneficiary contact email address"
        },
        "address": {
          "$ref": "#/$defs/Address"
        }
      },
      "description": "Beneficiary Contact Resource Object"
    },
    "BeneficiaryCreateConnect": {
      "type": "string",
      "description": "service provider selection type",
      "enum": [
        "explicit",
        "implicit",
        "explicit"
      ]
    },
    "BeneficiaryCreateMetadataContainer": {
      "type": "object"
    },
    "BeneficiaryCreateRequestDataContainer": {
      "type": "object",
      "properties": {
        "beneficiary": {
          "$ref": "#/$defs/Beneficiary"
        },
        "sourceId": {
          "type": "string",
          "description": "id of the beneficiary to be migrated, required if workflow is migration",
          "writeOnly": true
        }
      }
    },
    "BeneficiaryCreateWorkflow": {
      "type": "string",
      "description": "workflow code",
      "enum": [
        "direct",
        "client.direct",
        "organization.direct",
        "migration",
        "direct"
      ]
    },
    "BeneficiaryCreateWorkflowContainer": {
      "required": [
        "code"
      ],
      "type": "object",
      "properties": {
        "code": {
          "$ref": "#/$defs/BeneficiaryCreateWorkflow"
        }
      },
      "description": "workflow container"
    },
    "LegalEntityIdentity": {
      "required": [
        "type"
      ],
      "type": "object",
      "properties": {
        "type": {
          "type": "string"
        }
      }
    },
    "LegalEntityType": {
      "type": "string",
      "enum": [
        "corporate",
        "individual"
      ]
    },
    "RoutingCodeMap": {
      "type": "object"
    }
  }
}