> ## Documentation Index
> Fetch the complete documentation index at: https://developers.appstle.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate discount code for bundle

> Generates a discount code for a subscription bundle. This endpoint creates a Shopify discount code that can be applied to bundle subscriptions, typically used during the checkout process.

**Discount Code Generation:**
- Creates a unique discount code in Shopify
- Associates the discount with the bundle
- Configures discount rules and limitations
- Sets expiration dates if specified
- Applies usage limits if configured

**Discount Configuration Options:**
- Discount type (percentage, fixed amount, or free shipping)
- Discount value/amount
- Minimum purchase requirements
- Maximum usage count
- Expiration date
- Customer eligibility rules

**Use Cases:**
- Promotional campaigns for bundles
- Welcome discounts for new subscribers
- Loyalty rewards for existing customers
- Special offers and limited-time promotions
- Partner/affiliate discount codes

**Important Notes:**
- Discount codes are created in Shopify and follow Shopify's discount rules
- Codes can be single-use or multi-use depending on configuration
- Expired or depleted codes cannot be reused

**Authentication:** Requires valid X-API-Key header



## OpenAPI

````yaml /subscription/admin-api-swagger.json put /api/external/v2/subscription-bundlings/discount/{token}
openapi: 3.0.1
info:
  description: >-
    Comprehensive API documentation for managing subscriptions, payments, and
    related operations. These APIs allow you to programmatically manage
    subscription lifecycles, handle payments, configure products, and integrate
    subscription functionality into your applications.
  title: Admin APIs
  version: 0.0.1
servers:
  - url: https://subscription-admin.appstle.com
security: []
tags:
  - description: >-
      Core APIs for managing the complete subscription lifecycle including
      creation, updates, pausing, resuming, and cancellation of subscriptions.
    name: Subscription Management
  - description: >-
      APIs for managing subscription payment methods, processing payments,
      handling payment retries, and updating billing information.
    name: Subscription Payments
  - description: >-
      APIs for managing subscription contracts including delivery schedules,
      pricing, order notes, billing cycles, and shipping addresses.
    name: Subscription Contracts
  - description: >-
      APIs for managing products within subscriptions including adding,
      removing, updating quantities, and swapping products.
    name: Subscription Products
  - description: >-
      APIs for handling billing operations, payment processing, and financial
      transactions related to subscriptions.
    name: Billing & Payments
  - description: >-
      APIs for managing discounts and promotional codes applied to
      subscriptions.
    name: Subscription Discounts
  - description: >-
      APIs for managing one-time add-on products that can be purchased alongside
      recurring subscription items.
    name: Subscription One-Time Products
  - description: >-
      APIs for managing subscription plans, pricing tiers, and plan
      configurations.
    name: Subscription Plans
  - description: >-
      APIs for managing customizable product boxes and bundles where customers
      can select multiple items.
    name: Build-a-Box & Bundles
  - description: >-
      APIs for managing the product catalog including product information,
      variants, and inventory.
    name: Product Catalog
  - description: >-
      APIs for managing operational settings, configurations, and administrative
      functions.
    name: Operations & Settings
  - description: >-
      APIs powering the customer-facing portal where subscribers can manage
      their own subscriptions.
    name: Customer Portal
  - description: APIs for managing customer information, profiles, and account details.
    name: Customers
  - description: >-
      APIs for retrieving aggregated subscription data, customer subscription
      history, and account-level subscription information.
    name: Subscription Data
  - description: >-
      APIs for managing delivery profiles, shipping rates, free shipping
      configuration, and delivery method options on subscriptions.
    name: Delivery & Shipping
  - description: >-
      APIs for managing storefront customization including custom CSS, theme
      settings, label translations, and merchant-defined widget configuration.
    name: Customization
  - description: >-
      APIs for configuring cancellation flows, retention offers, cancellation
      reason management, and win-back automation.
    name: Customer Retention
paths:
  /api/external/v2/subscription-bundlings/discount/{token}:
    put:
      tags:
        - Build-a-Box & Bundles
      summary: Generate discount code for bundle
      description: >-
        Generates a discount code for a subscription bundle. This endpoint
        creates a Shopify discount code that can be applied to bundle
        subscriptions, typically used during the checkout process.


        **Discount Code Generation:**

        - Creates a unique discount code in Shopify

        - Associates the discount with the bundle

        - Configures discount rules and limitations

        - Sets expiration dates if specified

        - Applies usage limits if configured


        **Discount Configuration Options:**

        - Discount type (percentage, fixed amount, or free shipping)

        - Discount value/amount

        - Minimum purchase requirements

        - Maximum usage count

        - Expiration date

        - Customer eligibility rules


        **Use Cases:**

        - Promotional campaigns for bundles

        - Welcome discounts for new subscribers

        - Loyalty rewards for existing customers

        - Special offers and limited-time promotions

        - Partner/affiliate discount codes


        **Important Notes:**

        - Discount codes are created in Shopify and follow Shopify's discount
        rules

        - Codes can be single-use or multi-use depending on configuration

        - Expired or depleted codes cannot be reused


        **Authentication:** Requires valid X-API-Key header
      operationId: generateDiscountV2
      parameters:
        - description: Token
          in: path
          name: token
          required: true
          schema:
            type: string
        - description: API Key (Deprecated - Use Header X-API-Key instead)
          in: query
          name: api_key
          required: false
          schema:
            type: string
        - in: header
          name: X-API-Key
          required: false
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DiscountCodeRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              examples:
                Success Response:
                  description: Success Response
                  value:
                    active: true
                    currentUsageCount: 0
                    discountCode: BUNDLE10
                    discountId: gid://shopify/DiscountCodeNode/123456
                    discountType: PERCENTAGE
                    discountValue: 10
                    expiresAt: '2024-12-31T23:59:59Z'
                    usageLimit: 100
          description: Discount code successfully generated
        '400':
          content:
            application/json:
              examples:
                Invalid Discount Config:
                  description: Invalid Discount Config
                  value:
                    detail: Discount value must be greater than 0
                    status: 400
                    title: Invalid discount configuration
                    type: https://example.com/errors/bad-request
                Invalid Token:
                  description: Invalid Token
                  value:
                    detail: No bundle found for the specified token
                    status: 400
                    title: Invalid bundle token
                    type: https://example.com/errors/bad-request
          description: Invalid discount configuration or bundle token
        '401':
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/DiscountCodeResponse'
          description: Authentication required
        '403':
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/DiscountCodeResponse'
          description: Insufficient permissions
        '422':
          content:
            application/json:
              example:
                detail: Unable to create discount code in Shopify API
                status: 422
                title: Shopify discount creation failed
                type: https://example.com/errors/unprocessable-entity
          description: Unable to create discount in Shopify
components:
  schemas:
    DiscountCodeRequest:
      description: Discount Code Request
      properties:
        cart:
          $ref: '#/components/schemas/Cart'
      type: object
    DiscountCodeResponse:
      properties:
        discountAmount:
          format: double
          type: number
        discountCode:
          type: string
        discountNeeded:
          type: boolean
        errorMessage:
          type: string
      type: object
    Cart:
      properties:
        attributes:
          $ref: '#/components/schemas/Attributes'
        cart_level_discount_applications:
          items:
            type: object
          type: array
        currency:
          type: string
        item_count:
          format: int64
          type: integer
        items:
          items:
            $ref: '#/components/schemas/Item'
          type: array
        items_subtotal_price:
          format: int64
          type: integer
        note:
          type: object
        original_total_price:
          format: int64
          type: integer
        requires_shipping:
          type: boolean
        token:
          type: string
        total_discount:
          format: int64
          type: integer
        total_price:
          format: int64
          type: integer
        total_weight:
          format: int64
          type: integer
      type: object
    Attributes:
      type: object
    Item:
      properties:
        discounted_price:
          format: int64
          type: integer
        discounts:
          items:
            type: object
          type: array
        featured_image:
          $ref: '#/components/schemas/FeaturedImage'
        final_line_price:
          format: int64
          type: integer
        final_price:
          format: int64
          type: integer
        gift_card:
          type: boolean
        grams:
          format: int64
          type: integer
        handle:
          type: string
        id:
          format: int64
          type: integer
        image:
          type: string
        key:
          type: string
        line_level_discount_allocations:
          items:
            type: object
          type: array
        line_level_total_discount:
          format: int64
          type: integer
        line_price:
          format: int64
          type: integer
        options_with_values:
          items:
            $ref: '#/components/schemas/OptionsWithValue'
          type: array
        original_line_price:
          format: int64
          type: integer
        original_price:
          format: int64
          type: integer
        price:
          format: int64
          type: integer
        product_description:
          type: string
        product_has_only_default_variant:
          type: boolean
        product_id:
          format: int64
          type: integer
        product_title:
          type: string
        product_type:
          type: string
        properties:
          $ref: '#/components/schemas/Properties'
        quantity:
          format: int64
          type: integer
        requires_shipping:
          type: boolean
        sku:
          type: string
        taxable:
          type: boolean
        title:
          type: string
        total_discount:
          format: int64
          type: integer
        url:
          type: string
        variant_id:
          format: int64
          type: integer
        variant_options:
          items:
            type: string
          type: array
        variant_title:
          type: object
        vendor:
          type: string
      type: object
    FeaturedImage:
      properties:
        alt:
          type: string
        aspect_ratio:
          format: int64
          type: integer
        height:
          format: int64
          type: integer
        url:
          type: string
        width:
          format: int64
          type: integer
      type: object
    OptionsWithValue:
      properties:
        name:
          type: string
        value:
          type: string
      type: object
    Properties:
      type: object

````