{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/breezecash/json-schema/breezecash-create-subscription-request-schema.json",
  "title": "CreateSubscriptionRequest",
  "description": "Subscription details",
  "x-generated": "2026-10-29",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/breezecash-breeze-api-openapi.yml#/components/schemas/CreateSubscriptionRequest",
  "type": "object",
  "properties": {
    "clientReferenceId": {
      "type": "string"
    },
    "productId": {
      "type": "string"
    },
    "priceId": {
      "type": "string"
    },
    "customer": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        }
      },
      "required": [
        "id"
      ],
      "additionalProperties": false
    },
    "trial": {
      "type": "object",
      "properties": {
        "duration": {
          "type": "integer",
          "exclusiveMinimum": 0
        },
        "durationType": {
          "type": "string",
          "enum": [
            "hour",
            "day",
            "week",
            "month",
            "year"
          ]
        }
      },
      "required": [
        "duration",
        "durationType"
      ],
      "additionalProperties": false
    },
    "discountedTrial": {
      "type": "object",
      "properties": {
        "cycleCount": {
          "type": "integer",
          "minimum": 1
        },
        "billingCycleConfig": {
          "type": "object",
          "properties": {
            "interval": {
              "type": "string",
              "enum": [
                "hour",
                "day",
                "week",
                "month",
                "year"
              ]
            },
            "frequency": {
              "type": "integer",
              "minimum": 1
            }
          },
          "required": [
            "interval",
            "frequency"
          ],
          "additionalProperties": false
        },
        "price": {
          "type": "object",
          "properties": {
            "amountStr": {
              "type": "string",
              "deprecated": true
            },
            "unitAmount": {
              "type": "integer",
              "description": "Positive minor units / cents (e.g., currency: \"USD\", unitAmount: 10000 = USD 100). Mutually exclusive with amountStr.",
              "exclusiveMinimum": 0
            },
            "currency": {
              "type": "string",
              "enum": [
                "USD",
                "AUD",
                "CAD",
                "CHF",
                "DKK",
                "EUR",
                "GBP",
                "HKD",
                "JPY",
                "NOK",
                "NZD",
                "PLN",
                "SEK",
                "SGD",
                "TWD",
                "KRW",
                "SOL",
                "USDC",
                "USDT",
                "HONEY",
                "EURC"
              ]
            }
          },
          "required": [
            "currency"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "cycleCount",
        "billingCycleConfig",
        "price"
      ],
      "additionalProperties": false,
      "deprecated": true,
      "description": "Deprecated: use `phases` instead."
    },
    "startAt": {
      "type": "integer",
      "exclusiveMinimum": 0
    },
    "gracePeriodDays": {
      "type": "integer",
      "description": "Number of days after an invoice's due date before the subscription lapses for non-payment. When set, overrides the merchant-level grace period for this subscription; when omitted, the merchant setting (else the platform default) applies. Maximum 90 days.",
      "minimum": 0,
      "maximum": 90
    },
    "successReturnUrl": {
      "type": "string"
    },
    "failReturnUrl": {
      "type": "string"
    },
    "preferredPaymentMethods": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "enum": [
          "card",
          "saved_card",
          "apple_pay",
          "google_pay",
          "crypto",
          "crypto_wallet",
          "crypto_deposit"
        ]
      }
    },
    "phases": {
      "type": "array",
      "minItems": 1,
      "maxItems": 10,
      "items": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "cycleCount": {
                "type": "integer",
                "minimum": 1,
                "description": "Number of billing cycles this phase bills before advancing to the next phase. After the final phase is exhausted, the subscription falls back to its default price."
              },
              "priceId": {
                "type": "string",
                "description": "ID of an existing price to bill during this phase. The price must be active, recurring, belong to the same product as the subscription, and use the subscription's currency."
              }
            },
            "required": [
              "cycleCount",
              "priceId"
            ],
            "additionalProperties": false,
            "title": "Reference an existing price"
          },
          {
            "type": "object",
            "properties": {
              "cycleCount": {
                "type": "integer",
                "minimum": 1,
                "description": "Number of billing cycles this phase bills before advancing to the next phase. After the final phase is exhausted, the subscription falls back to its default price."
              },
              "price": {
                "type": "object",
                "properties": {
                  "unitAmount": {
                    "type": "integer",
                    "exclusiveMinimum": 0,
                    "description": "Amount in minor units / cents (e.g., 10000 = USD 100.00)."
                  },
                  "currency": {
                    "type": "string",
                    "enum": [
                      "USD",
                      "AUD",
                      "CAD",
                      "CHF",
                      "DKK",
                      "EUR",
                      "GBP",
                      "HKD",
                      "JPY",
                      "NOK",
                      "NZD",
                      "PLN",
                      "SEK",
                      "SGD",
                      "TWD",
                      "KRW",
                      "SOL",
                      "USDC",
                      "USDT",
                      "HONEY",
                      "EURC"
                    ],
                    "description": "Currency for this phase. Must match the subscription's currency."
                  },
                  "billingCycleConfig": {
                    "type": "object",
                    "properties": {
                      "interval": {
                        "type": "string",
                        "enum": [
                          "hour",
                          "day",
                          "week",
                          "month",
                          "year"
                        ],
                        "description": "Billing interval. Hourly billing (`hour`) is not supported in live mode."
                      },
                      "frequency": {
                        "type": "integer",
                        "minimum": 1
                      }
                    },
                    "required": [
                      "interval",
                      "frequency"
                    ],
                    "additionalProperties": false
                  }
                },
                "required": [
                  "unitAmount",
                  "currency",
                  "billingCycleConfig"
                ],
                "additionalProperties": false,
                "description": "Inline price to bill during this phase, used instead of referencing an existing price by ID."
              }
            },
            "required": [
              "cycleCount",
              "price"
            ],
            "additionalProperties": false,
            "title": "Define an inline price"
          }
        ]
      },
      "description": "Optional ordered pricing phases. Each phase bills its own price for a fixed number of billing cycles before advancing to the next phase; once all phases are exhausted the subscription falls back to its default price (the top-level `priceId`). Cannot be combined with `discountedTrial`."
    }
  },
  "required": [
    "clientReferenceId",
    "productId",
    "priceId",
    "customer"
  ],
  "additionalProperties": false
}