{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/recurly/json-schema/recurly-subscription-preview-basic-response-schema.json",
  "title": "SubscriptionPreviewBasicResponse",
  "x-generated": "2026-11-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/recurly-subscriptions-api-openapi.yml#/components/schemas/SubscriptionPreviewBasicResponse",
  "allOf": [
    {
      "$ref": "#/$defs/SubscriptionBase"
    },
    {
      "type": "object",
      "properties": {
        "href": {
          "type": "string",
          "default": ""
        }
      }
    },
    {
      "$ref": "#/$defs/SubscriptionSharedReferences"
    },
    {
      "$ref": "#/$defs/SubscriptionSharedResponseProperties"
    },
    {
      "$ref": "#/$defs/SubscriptionPreviewSharedResponseProperties"
    }
  ],
  "$defs": {
    "Address": {
      "type": "object",
      "properties": {
        "address1": {
          "type": "string"
        },
        "address2": {
          "type": "string"
        },
        "city": {
          "type": "string"
        },
        "state": {
          "type": "string"
        },
        "zip": {
          "type": "string"
        },
        "country": {
          "type": "string",
          "maxLength": 2
        },
        "phone": {
          "type": "string"
        }
      }
    },
    "AddressWithNameResponse": {
      "allOf": [
        {
          "$ref": "#/$defs/Address"
        },
        {
          "properties": {
            "name": {
              "type": "string",
              "description": "Full name comprised of `first_name` and `last_name`."
            }
          }
        }
      ]
    },
    "CostInCents": {
      "type": "integer",
      "minimum": 0
    },
    "CustomField": {
      "type": "object",
      "required": [
        "name",
        "value"
      ],
      "properties": {
        "name": {
          "type": "string",
          "maxLength": 50,
          "pattern": "/^[a-z0-9_-]+$/i",
          "title": "Field name",
          "description": "Fields must be created in the UI before values can be assigned to them."
        },
        "value": {
          "type": "string",
          "maxLength": 255,
          "title": "Field value",
          "description": "Any values that resemble a credit card number or security code (CVV/CVC) will be rejected."
        }
      }
    },
    "CustomFields": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/CustomField"
      },
      "title": "Custom Fields",
      "description": "The custom fields will only be altered when they are included in a request. Sending an empty array will not remove any existing values. To remove a field send the name with a null or empty value."
    },
    "ImportedTrial": {
      "type": "boolean",
      "description": "Indicates if the subscription is to be treated as an import for data analysis or a real trial. This value can only be changed on a trial subscription and is persisted for its lifetime.",
      "default": false
    },
    "InvoiceCollection": {
      "type": "array",
      "items": {
        "type": "object"
      }
    },
    "PlanCode": {
      "type": "string",
      "default": "",
      "maxLength": 50,
      "description": "Unique code to identify the plan. This code may only contain the following characters: [a-z 0-9 @ - _ .]. Max of 50 characters."
    },
    "PlanMini": {
      "type": "object",
      "properties": {
        "plan_code": {
          "$ref": "#/$defs/PlanCode"
        },
        "name": {
          "type": "string",
          "default": "",
          "maxLength": 255,
          "description": "Plan name. Max of 255 characters."
        }
      }
    },
    "ReferenceHref": {
      "type": "string",
      "format": "url"
    },
    "ReferencePlan": {
      "type": "object",
      "properties": {
        "href": {
          "$ref": "#/$defs/ReferenceHref"
        }
      }
    },
    "RevenueScheduleTypeEnum": {
      "type": "string",
      "description": "Optional field for setting a revenue schedule type. This will determine how revenue for the associated Subscription should be recognized. When creating a Subscription, available schedule types are `never`, `evenly`, `at_range_start`, or `at_range_end`. If no `revenue_schedule_type` is set, the Subscription will inherit the `revenue_schedule_type` from its Plan.",
      "enum": [
        "never",
        "evenly",
        "at_range_start",
        "at_range_end"
      ]
    },
    "SubscriptionAddOns": {
      "type": "array",
      "description": "Nested add-on information for the subscription. When creating, the new subscription will have no add-ons unless specified.",
      "items": {
        "type": "object"
      },
      "default": []
    },
    "SubscriptionBase": {
      "type": "object",
      "title": "Subscription"
    },
    "SubscriptionCommonFields": {
      "type": "object",
      "properties": {
        "uuid": {
          "type": "string",
          "title": "UUID",
          "description": "The UUID is useful for matching data with the CSV exports and building URLs into Recurly's UI.",
          "maxLength": 32
        },
        "state": {
          "$ref": "#/$defs/SubscriptionStateEnum"
        },
        "unit_amount_in_cents": {
          "type": "integer",
          "maximum": 10000000,
          "minimum": 0,
          "description": "Override the unit amount of the subscription plan by setting this value in cents. If not provided, the subscription will inherit the price from the subscription plan for the provided currency. Max 10000000."
        },
        "currency": {
          "type": "string",
          "description": "3-Letter currency code for the subscription."
        },
        "quantity": {
          "type": "integer",
          "default": 1,
          "minimum": 1,
          "description": "Optionally override the default quantity of 1."
        },
        "activated_at": {
          "type": "string",
          "format": "date-time"
        },
        "canceled_at": {
          "type": "string",
          "format": "date-time"
        },
        "expires_at": {
          "type": "string",
          "format": "date-time"
        },
        "updated_at": {
          "type": "string",
          "format": "date-time"
        },
        "total_billing_cycles": {
          "type": "integer",
          "description": "The total number of billing cycles for the current subscription term",
          "minimum": 1
        },
        "remaining_billing_cycles": {
          "type": "integer",
          "description": "The number of billing periods that are left in the subscription. `1` means the subscription renew one more time and then expire.  Decrements from the total number of billing periods in the current term. Will always be 0 if total billing cycles is 1.",
          "minimum": 0
        },
        "current_period_started_at": {
          "type": "string",
          "format": "date-time"
        },
        "current_period_ends_at": {
          "type": "string",
          "format": "date-time"
        },
        "trial_started_at": {
          "type": "string",
          "format": "date-time"
        },
        "trial_ends_at": {
          "type": "string",
          "format": "date-time",
          "description": "If set, overrides the default trial behavior for the subscription. This must be a date and time, preferably in UTC. If the date is in the past, the subscription will skip the trial."
        },
        "terms_and_conditions": {
          "type": "string",
          "description": "Optional notes field. This will default to the Terms and Conditions text specified on the Invoice Settings page in your Recurly admin. Specify custom notes with this tag to add or override Terms and Conditions. Custom notes will stay with a subscription on all renewals."
        },
        "customer_notes": {
          "type": "string",
          "description": "Optional notes field. This will default to the Customer Notes text specified on the Invoice Settings page in your Recurly admin. Specify custom notes with this tag to add or override Customer Notes. Custom notes will stay with a subscription on all renewals."
        },
        "action_result": {
          "type": "string",
          "description": "Action result params to be used in Recurly-JS to complete a payment when using asynchronous payment methods, e.g., Boleto, iDEAL and Sofort."
        }
      }
    },
    "SubscriptionImportedTrial": {
      "type": "object",
      "properties": {
        "imported_trial": {
          "$ref": "#/$defs/ImportedTrial"
        }
      }
    },
    "SubscriptionPausing": {
      "type": "object",
      "properties": {
        "remaining_pause_cycles": {
          "type": "integer",
          "description": "Number of billing cycles to pause the subscriptions. A value of 0 will cancel any pending pauses on the subscription.",
          "minimum": 0
        },
        "paused_at": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "SubscriptionPreviewSharedResponseProperties": {
      "type": "object",
      "properties": {
        "address": {
          "$ref": "#/$defs/AddressWithNameResponse"
        },
        "cost_in_cents": {
          "$ref": "#/$defs/CostInCents"
        },
        "invoice_collection": {
          "$ref": "#/$defs/InvoiceCollection"
        }
      }
    },
    "SubscriptionSharedReferences": {
      "type": "object",
      "properties": {
        "plan": {
          "allOf": [
            {
              "$ref": "#/$defs/ReferencePlan"
            },
            {
              "$ref": "#/$defs/PlanMini"
            }
          ]
        }
      }
    },
    "SubscriptionSharedResponseProperties": {
      "allOf": [
        {
          "$ref": "#/$defs/SubscriptionTerms"
        },
        {
          "$ref": "#/$defs/SubscriptionCommonFields"
        },
        {
          "$ref": "#/$defs/SubscriptionStartedWithGift"
        },
        {
          "$ref": "#/$defs/SubscriptionImportedTrial"
        },
        {
          "$ref": "#/$defs/SubscriptionPausing"
        },
        {
          "type": "object",
          "properties": {
            "revenue_schedule_type": {
              "$ref": "#/$defs/RevenueScheduleTypeEnum"
            },
            "no_billing_info_reason": {
              "type": "string",
              "default": ""
            },
            "gateway_code": {
              "type": "string",
              "default": "",
              "description": "An alphanumeric code shown per gateway on your site's payment gateways page. Set this code to ensure that a given subscription targets a given gateway."
            },
            "subscription_add_ons": {
              "$ref": "#/$defs/SubscriptionAddOns"
            },
            "custom_fields": {
              "$ref": "#/$defs/CustomFields"
            },
            "action_result": {
              "type": "string",
              "description": "Action result params to be used in Recurly-JS to complete a payment when using asynchronous payment methods, e.g., Boleto, iDEAL and Sofort."
            }
          }
        }
      ]
    },
    "SubscriptionStartedWithGift": {
      "type": "object",
      "properties": {
        "started_with_gift": {
          "type": "boolean",
          "default": false
        },
        "converted_at": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "SubscriptionStateEnum": {
      "type": "string",
      "enum": [
        "active",
        "canceled",
        "expired",
        "failed",
        "future",
        "paused"
      ]
    },
    "SubscriptionTerms": {
      "type": "object",
      "properties": {
        "auto_renew": {
          "type": "boolean",
          "default": true,
          "description": "Determines if subscription configured to auto renew for another term or expire at the end of current term."
        },
        "renewal_billing_cycles": {
          "type": "integer",
          "description": "The number of billing periods in the subscription's next term. Will default to the plan's total_billing_cycles unless specified."
        },
        "current_period_started_at": {
          "type": "string",
          "format": "date-time"
        },
        "current_period_ends_at": {
          "type": "string",
          "format": "date-time"
        }
      }
    }
  }
}