{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/canopyservicing-com/json-schema/canopyservicing-com-create-account-request-schema.json",
  "title": "CreateAccountRequest",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/canopyservicing-com-accounts-api-openapi.yml#/components/schemas/CreateAccountRequest",
  "properties": {
    "product_id": {
      "type": "string",
      "title": "Product Id",
      "description": "The product id to use for this account",
      "hidden": false
    },
    "account_id": {
      "type": "string",
      "title": "Account Id",
      "description": "The account id to use for this account. If not provided, a new account id will be generated."
    },
    "template_id": {
      "type": "string",
      "title": "Template Id",
      "description": "The template id to use for this account",
      "hidden": false
    },
    "assign_borrowers": {
      "items": {
        "$ref": "#/$defs/AssignBorrower"
      },
      "type": "array",
      "title": "Assign Borrowers",
      "description": "The borrowers to assign to this account. If not provided, a secondary call will be needed to assign a borrower to the account."
    },
    "external_fields": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "items": {
            "additionalProperties": true,
            "type": "object"
          },
          "type": "array"
        },
        {
          "items": {},
          "type": "array"
        }
      ],
      "title": "External Fields",
      "description": "The external fields to use for this account. If not provided, a secondary call will be needed to assign external fields to the account.",
      "hidden": false
    },
    "originating_organization_name": {
      "type": "string",
      "title": "Originating Organization Name",
      "description": "The name of the organization that originated the account. If not provided, defaults to the calling user's organization name."
    }
  },
  "type": "object",
  "required": [
    "product_id",
    "template_id"
  ],
  "$defs": {
    "AssignBorrower": {
      "properties": {
        "borrower_id": {
          "type": "string",
          "title": "Borrower Id",
          "description": "The borrower id to assign to this account",
          "hidden": false
        },
        "borrower_account_id": {
          "type": "string",
          "title": "Borrower Account Id",
          "description": "The borrower account id to assign to this account. If not provided, a new borrower account id will be generated."
        },
        "borrower_account_role": {
          "$ref": "#/$defs/BorrowerAccountRole",
          "description": "The role of the borrower in this account. If not provided, the borrower will be assigned as a secondary borrower."
        }
      },
      "type": "object",
      "required": [
        "borrower_id"
      ],
      "title": "AssignBorrower"
    },
    "BorrowerAccountRole": {
      "type": "string",
      "enum": [
        "PRIMARY",
        "SECONDARY"
      ],
      "title": "BorrowerAccountRole"
    }
  }
}