{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/swoogo/json-schema/swoogo-discount-create-request-schema.json",
  "title": "discountCreateRequest",
  "x-generated": "2026-11-24",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/swoogo-openapi.yml#/components/schemas/discountCreateRequest",
  "type": "object",
  "required": [
    "event_id",
    "code",
    "type"
  ],
  "properties": {
    "event_id": {
      "type": "integer",
      "description": "ID of the event to which this discount is associated."
    },
    "parent_id": {
      "type": "integer",
      "description": "Creates this code as an alternate (child) of the given primary code. The parent must be an existing,\nnon-deleted, top-level code in the same event; otherwise the request is rejected with `422`.\nAn alternate inherits everything from its parent: `capacity`, `min_group_size`, `registrants_per_use`,\n`percentage_discount`, `absolute_discount`, `apply_to_all`, `applicable_line_items`, `custom_fees`,\n`notes`, `sold_out_message`, `all_registrants_in_group`, `autopopulate_attributes` and visibility. Any of these sent alongside `parent_id` are ignored,\nand checkout always applies the parent's `type` and amount (the alternate's own `type` is informational only).\nEach alternate still tracks its own usage count against the inherited `capacity`.\nSo the only fields worth sending with `parent_id` are `event_id`, `code` and `type`.\n"
    },
    "code": {
      "type": "string",
      "maxLength": 255,
      "description": "Unique code for the discount within the event. May not contain `<`, `>`, `\\`, or `\"`."
    },
    "type": {
      "type": "string",
      "enum": [
        "percentage",
        "absolute",
        "specific"
      ],
      "description": "The type of discount being applied.\n- `percentage` — `percentage_discount` is required.\n- `absolute` — `absolute_discount` is required.\n- `specific` — line-item-specific fees are supplied via `custom_fees_update`.\n"
    },
    "percentage_discount": {
      "type": "number",
      "format": "float",
      "minimum": 0,
      "maximum": 100,
      "description": "Percentage value of the discount. Required when `type` is `percentage`."
    },
    "absolute_discount": {
      "type": "number",
      "format": "float",
      "description": "Absolute monetary value of the discount. Required when `type` is `absolute`."
    },
    "apply_to_all": {
      "type": "boolean",
      "description": "If `true`, the discount applies to every line item; if `false`, only to those listed in `applicable_line_items`."
    },
    "capacity": {
      "type": "integer",
      "description": "Maximum number of times this discount can be used. Omit (or `0`) for unlimited."
    },
    "min_group_size": {
      "type": "integer",
      "minimum": 2,
      "description": "Minimum group size required to use this discount."
    },
    "registrants_per_use": {
      "type": "integer",
      "minimum": 2,
      "description": "Maximum number of times the code can be used per group of N registrants. e.g. set to `2` to allow 1 use in a group of 2, 2 uses in a group of 4, etc."
    },
    "all_registrants_in_group": {
      "type": "boolean",
      "description": "Whether all registrants in a group must use the same discount."
    },
    "applicable_line_items": {
      "type": "array",
      "description": "Line items the discount applies to when `apply_to_all` is `false`. Standard values are\n`reg_type`, `package`, and `session`. Custom-question line items use the form `c_<questionId>`\n(e.g. `c_438`).\n",
      "items": {
        "type": "string"
      }
    },
    "custom_fees_update": {
      "type": "object",
      "description": "For `specific` discounts: maps each line-item type to a map of line-item IDs and the\nreplacement fee (as a string). On save, these entries are merged into the persisted\n`custom_fees` object. Returned only via the `custom_fees` field on read responses.\n",
      "additionalProperties": {
        "type": "object",
        "additionalProperties": {
          "type": "string"
        }
      }
    },
    "autopopulate_attributes": {
      "type": "array",
      "description": "Registrant fields to be automatically populated when this discount is applied. Each entry\nhas an `attribute` (registrant attribute name or `c_<questionId>` for custom questions)\nand a `value`.\n",
      "items": {
        "type": "object",
        "properties": {
          "attribute": {
            "type": "string"
          },
          "value": {
            "description": "The value to set on the registrant (any scalar; `null` clears the field)."
          }
        }
      }
    },
    "notes": {
      "type": "string",
      "description": "Free-form notes or comments about the discount."
    },
    "sold_out_message": {
      "type": "string",
      "maxLength": 255,
      "description": "Custom message shown when the discount is sold out. Defaults to a generic message when not set."
    }
  }
}