{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/canopyservicing-com/json-schema/canopyservicing-com-create-installment-loan-request-schema.json",
  "title": "CreateInstallmentLoanRequest",
  "description": "Request schema for creating an installment loan.",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/canopyservicing-com-installment-loans-api-openapi.yml#/components/schemas/CreateInstallmentLoanRequest",
  "properties": {
    "loan_id": {
      "type": "string",
      "title": "Loan Id",
      "description": "A unique value to set as Loan's ID. Auto-generated if not provided."
    },
    "original_amount_cents": {
      "type": "integer",
      "title": "Original Amount Cents",
      "description": "The initial amount of the loan in the smallest unit of the currency (e.g., cents for USD).",
      "hidden": false
    },
    "currency": {
      "type": "string",
      "title": "Currency",
      "description": "The ISO 4217 3-letter currency code of the loan.",
      "default": "USD",
      "hidden": false
    },
    "description": {
      "type": "string",
      "title": "Description",
      "description": "The loan's description."
    },
    "metadata": {
      "additionalProperties": {},
      "type": "object",
      "title": "Metadata",
      "description": "The metadata field can be used to store any loan metadata (for example, to link the loan to external systems/transactions)."
    },
    "template_id": {
      "type": "string",
      "title": "Template Id",
      "description": "The ID of the pre-defined loan terms' template that will be used for creating this loan.",
      "hidden": false
    },
    "template_parameters": {
      "$ref": "#/$defs/LoanTermsParameters",
      "description": "Specific parameters of the loan terms' template."
    }
  },
  "type": "object",
  "required": [
    "original_amount_cents",
    "template_id"
  ],
  "$defs": {
    "LoanTermsParameters": {
      "properties": {
        "term_length": {
          "type": "integer",
          "title": "Term Length",
          "description": "The number of periods over which the loan will amortize."
        },
        "period_interval": {
          "type": "string",
          "title": "Period Interval",
          "description": "Interval of an amortization period."
        },
        "due_date_offset": {
          "type": "string",
          "title": "Due Date Offset",
          "description": "The number of days after period_interval ends, at which time the account becomes delinquent if the due payment was not made."
        },
        "first_period_interval": {
          "type": "string",
          "title": "First Period Interval",
          "description": "The interval of the first amortization period."
        },
        "interest_rate_percent": {
          "anyOf": [
            {
              "type": "number",
              "maximum": 100,
              "minimum": 0
            },
            {
              "type": "string"
            }
          ],
          "title": "Interest Rate Percent",
          "description": "Annual interest rate as a percentage.",
          "hidden": false
        },
        "origination_fee_cents": {
          "type": "integer",
          "title": "Origination Fee Cents",
          "description": "The fee charged at the time of loan origination."
        },
        "origination_fee_percent": {
          "type": "number",
          "title": "Origination Fee Percent",
          "description": "The fee as a percent of `initial_principal_cents` charged at the time of account origination."
        }
      },
      "type": "object",
      "title": "LoanTermsParameters"
    }
  }
}