> ## 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 bundle-specific discount code

> Creates a Shopify discount code specifically for a subscription bundle. This endpoint generates unique, single-use or multi-use discount codes tied to bundle purchases.

**Key Features:**
- **Bundle-Specific Codes**: Discounts that apply only to specific bundles
- **Flexible Discount Types**: Percentage off, fixed amount off, or free shipping
- **Usage Limits**: Single-use, limited use, or unlimited codes
- **Expiration Dates**: Set validity periods for promotional campaigns
- **Minimum Requirements**: Minimum purchase amount or quantity thresholds
- **Customer Eligibility**: Restrict to specific customer segments or tags

**Discount Configuration:**
- **Code Format**: Custom code or auto-generated random code
- **Discount Value**: Percentage (e.g., 15%) or fixed amount (e.g., $10)
- **Start/End Dates**: Campaign duration controls
- **Usage Limit**: Max number of times code can be used
- **Once Per Customer**: Prevent code reuse by same customer
- **Bundle Association**: Links discount to specific bundle token

**Use Cases:**
- Create promotional codes for bundle launches
- Generate unique codes for influencer campaigns
- Offer first-time subscriber discounts on bundles
- Seasonal or holiday bundle promotions
- Referral program discount codes
- Partner/affiliate exclusive bundle offers

**Authentication:** Requires API key authentication via X-API-Key header or api_key parameter



## OpenAPI

````yaml /memberships/admin-api-swagger.json put /api/external/v2/subscription-bundlings/discount/{token}
openapi: 3.0.1
info:
  description: >-
    Comprehensive API documentation for managing memberships, payments, and
    related operations. These APIs allow you to programmatically manage
    membership lifecycles, handle payments, configure products, and integrate
    membership functionality into your applications.
  title: Admin APIs
  version: 0.0.1
servers:
  - url: https://membership-admin.appstle.com
security: []
tags:
  - description: >-
      APIs for managing Shopify delivery profiles, shipping rates, zones, and
      free shipping configuration for subscription memberships
    name: Shipping & Delivery Profiles
  - description: >-
      APIs for retrieving historical discount code usage and redemption
      information for membership contracts
    name: Customer Discount History
  - description: >-
      APIs for managing membership cancellation flow settings including
      retention offers, survey questions, and cancel confirmation screens
    name: Cancellation Flow Configuration
  - description: >-
      APIs for managing membership billing attempts, recurring orders, payment
      retries, order history, and order skipping
    name: Billing & Orders
  - description: >-
      APIs for managing one-time product additions to upcoming subscription
      orders, including adding, retrieving, and removing one-off items
    name: One-Time Add-Ons
  - description: >-
      APIs for managing membership/subscription plan groups, including creating
      plans, configuring discounts, billing intervals, and assigning products to
      plans
    name: Membership Plans
  - description: >-
      APIs for managing subscription product bundles, bundle configurations,
      item grouping, and bundle-specific discount codes
    name: Product Bundles
  - description: >-
      APIs for retrieving custom CSS styles applied to subscription widgets and
      customer portal for theme customization
    name: Custom CSS Styling
  - description: >-
      APIs for managing customer portal settings including UI customization,
      text labels, feature toggles, and branding options for the member
      self-service portal
    name: Customer Portal Configuration
  - description: >-
      APIs for managing membership/subscription contracts including creation,
      updates, status changes, line items, discounts, and billing operations
    name: Membership Contracts
  - description: >-
      APIs for managing subscription bundle configuration settings including
      bundle behavior, pricing rules, and display options
    name: Bundle Settings
  - description: >-
      APIs for managing customer payment methods, payment tokens, and payment
      method retrieval for subscriptions
    name: Customer Payment Methods
  - description: >-
      APIs for retrieving product swap/substitution options allowing members to
      exchange subscription items based on configured swap rules and variant
      groups
    name: Product Swap Rules
  - description: >-
      APIs for retrieving product catalog, variants, pricing, and inventory
      information for subscription memberships.
    name: Product & Inventory Data
  - description: >-
      APIs for managing shop-level membership settings, configuration, and
      general store information.
    name: Shop Settings
  - description: >-
      APIs for performing bulk/mass operations on multiple membership contracts
      including status updates, product replacements, and billing date changes.
    name: Bulk Operations
paths:
  /api/external/v2/subscription-bundlings/discount/{token}:
    put:
      tags:
        - Product Bundles
      summary: Generate bundle-specific discount code
      description: >-
        Creates a Shopify discount code specifically for a subscription bundle.
        This endpoint generates unique, single-use or multi-use discount codes
        tied to bundle purchases.


        **Key Features:**

        - **Bundle-Specific Codes**: Discounts that apply only to specific
        bundles

        - **Flexible Discount Types**: Percentage off, fixed amount off, or free
        shipping

        - **Usage Limits**: Single-use, limited use, or unlimited codes

        - **Expiration Dates**: Set validity periods for promotional campaigns

        - **Minimum Requirements**: Minimum purchase amount or quantity
        thresholds

        - **Customer Eligibility**: Restrict to specific customer segments or
        tags


        **Discount Configuration:**

        - **Code Format**: Custom code or auto-generated random code

        - **Discount Value**: Percentage (e.g., 15%) or fixed amount (e.g., $10)

        - **Start/End Dates**: Campaign duration controls

        - **Usage Limit**: Max number of times code can be used

        - **Once Per Customer**: Prevent code reuse by same customer

        - **Bundle Association**: Links discount to specific bundle token


        **Use Cases:**

        - Create promotional codes for bundle launches

        - Generate unique codes for influencer campaigns

        - Offer first-time subscriber discounts on bundles

        - Seasonal or holiday bundle promotions

        - Referral program discount codes

        - Partner/affiliate exclusive bundle offers


        **Authentication:** Requires API key authentication via X-API-Key header
        or api_key parameter
      operationId: generateDiscountV2
      parameters:
        - description: Bundle token identifier
          example: abc123xyz
          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'
        description: Discount code configuration including code, value, type, and validity
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DiscountCodeResponse'
          description: Discount code successfully created in Shopify
        '400':
          content:
            application/json:
              example:
                detail: Invalid discount code format or configuration
                errorKey: validation_error
                status: 400
                title: Bad Request
          description: Invalid discount configuration
        '401':
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/DiscountCodeResponse'
          description: Authentication required - invalid or missing API key
        '404':
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/DiscountCodeResponse'
          description: Bundle not found with specified token
        '500':
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/DiscountCodeResponse'
          description: Shopify API error during discount code creation
components:
  schemas:
    DiscountCodeRequest:
      properties:
        cart:
          $ref: '#/components/schemas/Cart'
      type: object
    DiscountCodeResponse:
      properties:
        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

````