title: Discount
x-tags:
  - Catalog
type: object
description: Defines a discount that is applied by a merchant against an order or specific line items.
required:
  - uuid
  - model_type
  - name
  - tags
  - calculation
  - product_group
  - availability
  - promo_code
  - description
  - total_redemption_limit
  - daily_redemption_limit
  - total_user_redemption_limit
  - daily_user_redemption_limit
  - allow_redemption_alongside_others
  - auto_apply
  - minimum_sub_total_spend
  - qty_allocation_mechanics
  - created_at
properties:
  uuid:
    type: string
    format: uuid
    description: The discount's unique identifier.
    readOnly: true
  model_type:
    enum:
      - discount
    readOnly: true
  name:
    type: string
    minLength: 1
    maxLength: 255
    description: The discount's display name.
    example: 'Buy 1, Get 1 Free'
  tags:
    type: array
    uniqueItems: true
    description: The discount's tags.
    items:
      type: string
      format: uuid
  calculation:
    allOf:
      - $ref: ./Calculation.yaml
      - type: object
        required:
          - type
          - fixed_value
          - percentage
          - percentage_cap
          - price_override
    description: |-
      The discount's calculation.

      Discounts may use `fixed`, `percentage`, or `price_override` calculations.
  product_group:
    type:
      - string
      - 'null'
    format: uuid
    description: |-
      The uuid of the product group that the discount should be applied against.

      This field is required when `calculation.type` is `price_override` or when quantity allocation mechanics are configured.
  availability:
    $ref: ./Availability.yaml
  promo_code:
    type:
      - string
      - 'null'
    minLength: 1
    maxLength: 255
    example: B1G1F
    description: |-
      The promo code associated with the discount.

      This can only be set when creating the discount, and cannot be changed.
  description:
    type:
      - string
      - 'null'
    minLength: 1
    maxLength: 255
    description: A user-friendly description of the discount.
    example: Buy anything and get another anything free!
  total_redemption_limit:
    type:
      - integer
      - 'null'
    minimum: 1
    description: The total number of redemptions permitted.
  daily_redemption_limit:
    type:
      - integer
      - 'null'
    minimum: 1
    description: The total number of redemptions permitted per calendar day.
  total_user_redemption_limit:
    type:
      - integer
      - 'null'
    minimum: 1
    description: The total number of redemptions permitted per user.
  daily_user_redemption_limit:
    type:
      - integer
      - 'null'
    minimum: 1
    description: 'The total number of redemptions permitted per user, per calendar day.'
  allow_redemption_alongside_others:
    type: boolean
    description: |-
      Indicates if this discount can be redeemed alongside other discounts in the same cart/order.

      This field may only be `false` for a discount that has a non-null `promo_code`.
  auto_apply:
    type: boolean
    description: 'Indicates if this discount will automatically apply, assuming all other conditions are met.'
  minimum_sub_total_spend:
    oneOf:
      - type: 'null'
      - $ref: ./Money.yaml
  qty_allocation_mechanics:
    type:
      - object
      - 'null'
    description: The mechanics that control the behaviour of a quantity-based discount.
    required:
      - trigger_product_group
      - trigger_qty
      - discount_qty
      - allocation_limit
    properties:
      trigger_product_group:
        type: string
        format: uuid
        description: The uuid of the product group that should trigger the discount.
      trigger_qty:
        type: integer
        minimum: 1
        description: The required qty of items from the `trigger_product_group` that must be present to trigger the discount.
      discount_qty:
        type: integer
        minimum: 1
        description: The qty of items from the `product_group` that should be discounted when the trigger is activated.
      allocation_limit:
        type:
          - integer
          - 'null'
        minimum: 1
        description: The maximum number of times the discount should be applied in a single cart.
  created_at:
    type: string
    format: date-time
    description: The date-time that the discount was created.
    readOnly: true
