{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/nmi/json-schema/nmi-plan-update-request-schema.json",
  "title": "Plan Update Request",
  "description": "Update an existing plan. The plan being updated is identified by the `{id}` path parameter. Body fields are optional; send only the fields to change. When changing the billing schedule, include a complete monthly (`month_frequency` + `day_of_month`) or daily (`day_frequency`) set.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/nmi-plans-api-openapi.yml#/components/schemas/PlanUpdateRequest",
  "type": "object",
  "allOf": [
    {
      "$ref": "#/$defs/PlanCreateRequest"
    },
    {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "maxLength": 50,
          "description": "New plan identifier when renaming the plan. Omit to keep the existing ID from the path. Distinct from the path parameter `{id}`, which identifies the plan being updated."
        },
        "plan_name": {
          "type": "string",
          "maxLength": 50,
          "description": "Updated display name of the plan. Optional on update."
        },
        "current_plan_id": {
          "type": "string",
          "maxLength": 50,
          "description": "Existing plan ID being updated. Optional; the path parameter `{id}` is authoritative and is applied when this is omitted or differs."
        }
      }
    }
  ],
  "$defs": {
    "PlanCreateRequest": {
      "type": "object",
      "required": [
        "plan_amount",
        "plan_payments"
      ],
      "properties": {
        "plan_amount": {
          "type": "number",
          "minimum": 0,
          "description": "The plan amount to be charged each billing cycle. Format: `x.xx`"
        },
        "plan_payments": {
          "type": "integer",
          "minimum": 0,
          "maximum": 999,
          "description": "The number of payments before the recurring plan is complete. Use '0' for until canceled"
        },
        "id": {
          "type": "string",
          "maxLength": 50,
          "description": "The unique identifier for the plan. Required when creating a plan directly; optional when defining a custom plan inline via a subscription."
        },
        "plan_name": {
          "type": "string",
          "maxLength": 50,
          "description": "The display name of the plan"
        }
      },
      "oneOf": [
        {
          "title": "Monthly Plan",
          "required": [
            "month_frequency",
            "day_of_month"
          ],
          "properties": {
            "month_frequency": {
              "type": "integer",
              "minimum": 1,
              "maximum": 24,
              "description": "How often, in months, to charge the customer."
            },
            "day_of_month": {
              "type": "integer",
              "minimum": 1,
              "maximum": 31,
              "description": "The day of the month that the customer will be charged. For months without 29, 30, or 31 days, the charge will be on the last day."
            }
          }
        },
        {
          "title": "Daily Plan",
          "required": [
            "day_frequency"
          ],
          "properties": {
            "day_frequency": {
              "type": "integer",
              "minimum": 1,
              "description": "How often, in days, to charge the customer."
            }
          }
        }
      ]
    }
  }
}