{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/recurly/json-schema/recurly-add-on-schema.json",
  "title": "AddOn",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_original/recurly-v2-v2.29-api.yaml#/components/schemas/AddOn",
  "type": "object",
  "properties": {
    "plan_code": {
      "type": "string",
      "description": "Unique code to identify the plan."
    },
    "plan": {
      "type": "string",
      "description": "The URL of the plan the add-on is in."
    },
    "measured_unit": {
      "type": "string",
      "description": "If the add-on is usage-based, this is the URL of the measured unit associated with the add-on."
    },
    "add_on_code": {
      "type": "string",
      "description": "The add-on code. Max of 50 characters."
    },
    "item_code": {
      "type": "string",
      "description": "Item code for an existing active item to be used as an add-on on the plan. This will be unique identifier for add-on within the plan."
    },
    "name": {
      "type": "string",
      "description": "The add-on name. Max of 255 characters."
    },
    "default_quantity": {
      "type": "integer",
      "description": "Default quantity for the hosted pages, defaults to 1."
    },
    "display_quantity_on_hosted_page": {
      "type": "boolean",
      "description": "If true, displays a quantity field on the hosted pages for the add-on."
    },
    "tax_code": {
      "type": "string",
      "maxLength": 50,
      "title": "Tax code",
      "description": "Optional field used by Avalara, Vertex, and Recurly's In-the-Box tax solution to determine taxation rules. You can pass in specific tax codes using any of these tax integrations. For Recurly's In-the-Box tax offering you can also choose to instead use simple values of `unknown`, `physical`, or `digital` tax codes. If `item_code`/`item_id` is part of the request then `tax_code` must be absent."
    },
    "unit_amount_in_cents": {
      "type": "array",
      "items": {
        "type": "object"
      },
      "description": "Array of unit amounts with their currency code. Max 10000000. Ex. $5.00 USD would be <USD>500</USD>. `unit_amount_in_cents` is not allowed when creating or updating a tiered add-on."
    },
    "accounting_code": {
      "type": "string",
      "description": "Accounting code for invoice line items for the add-on. Max of 20 characters."
    },
    "add_on_type": {
      "type": "string",
      "description": "Whether the add-on type is Fixed (fixed), or Usage-Based (usage). If `item_code` is present, `add_on_type` must be absent."
    },
    "optional": {
      "type": "boolean",
      "description": "Whether the add-on is optional for the customer to include in their purchase on the hosted payment page. If false, the add-on will be included when a subscription is created through the Recurly UI. However, the add-on will not be included when a subscription is created through the API. See https://dev.recurly.com/docs/subscription-add-ons for how to create a subscription with add-ons using the API."
    },
    "usage_type": {
      "type": "string",
      "description": "If `add_on_type` = `usage`, you will see `usage_type`, which can be `price` or `percentage`. If `price`, the price is defined in `unit_amount_in_cents`. If `percentage`, the percentage is defined in `usage_percentage`."
    },
    "usage_calculation_type": {
      "type": "string",
      "description": "The method used to calculate usage for a billing period.  Can be null, `cumulative`, or `last_in_period`.  If no value is specified, behavior will default to cumulative billing.  For cumulative billing, all usage records for the billing period will be summed together.  For last-in-period billing, only the last recorded usage record in the billing period will be used."
    },
    "usage_percentage": {
      "$ref": "#/$defs/UsagePercentage"
    },
    "revenue_schedule_type": {
      "type": "string",
      "description": "Optional field for setting a revenue schedule type. This will determine how revenue for the associated Plan should be recognized. When creating a Plan, if you supply an `end_date` and `end_date` available schedule types are `never`, `evenly`, `at_range_start`, or `at_range_end`."
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "description": "When the add-on was created in the plan."
    },
    "updated_at": {
      "type": "string",
      "format": "date-time",
      "description": "When the add-on was last updated."
    },
    "tier_type": {
      "type": "string",
      "description": "Add-on tier type. Defaults to flat which charges a fixed price per unit. When tiered-pricing is used, tier_type can be tiered, volume or stairstep. For more info, see our product docs (https://docs.recurly.com/docs/billing-models#section-quantity-based). This value cannot be changed after it has been saved."
    },
    "tiers": {
      "$ref": "#/$defs/Tiers"
    },
    "percentage_tiers": {
      "$ref": "#/$defs/PlanPercentageTiers"
    }
  },
  "required": [
    "plan_code"
  ],
  "$defs": {
    "PercentageTierCollection": {
      "type": "object",
      "title": "Percentage Tier",
      "required": [
        "currency",
        "tiers"
      ],
      "properties": {
        "currency": {
          "type": "string",
          "title": "currency"
        },
        "tiers": {
          "$ref": "#/$defs/PercentageTiersArray"
        }
      }
    },
    "PercentageTierObject": {
      "type": "object",
      "title": "Tier",
      "required": [
        "ending_amount_in_cents",
        "usage_percentage"
      ],
      "properties": {
        "ending_amount_in_cents": {
          "type": "integer",
          "title": "Ending amount in cents"
        },
        "usage_percentage": {
          "$ref": "#/$defs/TierUsagePercentage"
        }
      }
    },
    "PercentageTiersArray": {
      "type": "array",
      "title": "Percentage Tiers",
      "items": {
        "$ref": "#/$defs/PercentageTierObject"
      }
    },
    "PlanPercentageTiers": {
      "type": "array",
      "description": "Required if `tier_type != \"flat\"` and `usage_type == \"percentage\"`.\nArray of objects which must have at least one set of tiers\nper currency and the currency code. The tier_type must be `volume` or `tiered`,\nif not, it must be absent. There must be one tier without an `ending_amount_in_cents` value\nwhich represents the final tier.\n",
      "items": {
        "$ref": "#/$defs/PercentageTierCollection"
      }
    },
    "Tier": {
      "type": "object",
      "title": "Tier",
      "required": [
        "ending_quantity",
        "unit_amount_in_cents"
      ],
      "properties": {
        "ending_quantity": {
          "type": "integer",
          "title": "Ending quantity",
          "description": "Upper limit for the tier."
        },
        "unit_amount_in_cents": {
          "type": "integer",
          "title": "Unit amount in cents",
          "description": "Monetary amount to charge for a tier."
        }
      }
    },
    "TierUsagePercentage": {
      "type": "string",
      "pattern": "^(100(\\.0{1,4})?|\\d{1,2}(\\.\\d{1,4})?)$",
      "description": "The percentage taken of the monetary amount of usage tracked. This can be up to 4 decimal places. A value between 0.0000 and 100.0."
    },
    "Tiers": {
      "type": "array",
      "title": "Tiers",
      "description": "If the `tier_type` is `flat`, then `tiers` must be absent. The `tiers` object must include one to many tiers with `ending_quantity` and `unit_amount_in_cents` for the desired currencies. There must be one tier with an `ending_quantity` of 999999999 which is the default if not provided.",
      "items": {
        "$ref": "#/$defs/Tier"
      }
    },
    "UsagePercentage": {
      "type": "string",
      "pattern": "^(100(\\.0{1,4})?|\\d{1,2}(\\.\\d{1,4})?)$",
      "description": "The percentage taken of the monetary amount of usage tracked. This can be up to 4 decimal places. A value between 0.0000 and 100. Required if `add_on_type` is usage, `usage_type` is percentage and `tier_type` = `flat`. Must be omitted otherwise. For percentage tiered add ons use the percentage_tiers object."
    }
  }
}