> ## 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.

# Get product swap options for subscription items

> Retrieves available product swap/substitution options for specified variants based on configured swap rules. Returns multiple levels of swap suggestions allowing members to exchange products in their subscriptions.

**Key Features:**
- **Variant-Based Swaps**: Get swap options for specific product variants
- **Multi-Level Suggestions**: Returns up to 4 levels of swap alternatives
- **Quantity Preservation**: Maintains quantities when suggesting swaps
- **Recurring Order Rules**: Only returns swaps configured for every recurring order
- **Group-Based Matching**: Uses variant groups to find compatible swaps
- **Product Enrichment**: Includes product details (title, price, images)

**How Swap Rules Work:**
1. Merchant configures swap rules defining which products can substitute others
2. Rules are organized by variant groups (e.g., coffee roasts, tea flavors)
3. Each rule specifies "from" variants and "to" variants
4. Rules can be limited to specific subscription frequencies or all orders
5. Members can swap products within the allowed groups

**Request Structure:**
- **Variant Quantity List**: Array of variant IDs with quantities
- Each entry contains variant ID and quantity
- System finds swap options for all provided variants

**Response Structure:**
- Returns nested list of swap options (up to 5 levels)
- Level 0: Original variants (as provided in request)
- Levels 1-4: Progressive swap suggestions
- Each level contains variant IDs, quantities, titles, prices, images
- Variants appear with full Shopify product data

**Use Cases:**
- Display product swap options in customer portal
- Allow members to switch between flavor/size variants
- Build custom product selection interfaces
- Enable seasonal product swaps (summer/winter varieties)
- Offer alternative products when items are out of stock
- Let members customize subscriptions within allowed product groups

**Example Scenario:**
Member has "Dark Roast Coffee (12oz)" in subscription. API returns:
- Level 0: Dark Roast Coffee 12oz (original)
- Level 1: Medium Roast Coffee 12oz, Light Roast Coffee 12oz
- Level 2: Dark Roast Coffee 16oz, Decaf Dark Roast 12oz
- Level 3: Espresso Blend 12oz, French Roast 12oz
- Level 4: Additional variants based on swap rules

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



## OpenAPI

````yaml /memberships/admin-api-swagger.json post /api/external/v2/product-swaps-by-variant-groups
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/product-swaps-by-variant-groups:
    post:
      tags:
        - Product Swap Rules
      summary: Get product swap options for subscription items
      description: >-
        Retrieves available product swap/substitution options for specified
        variants based on configured swap rules. Returns multiple levels of swap
        suggestions allowing members to exchange products in their
        subscriptions.


        **Key Features:**

        - **Variant-Based Swaps**: Get swap options for specific product
        variants

        - **Multi-Level Suggestions**: Returns up to 4 levels of swap
        alternatives

        - **Quantity Preservation**: Maintains quantities when suggesting swaps

        - **Recurring Order Rules**: Only returns swaps configured for every
        recurring order

        - **Group-Based Matching**: Uses variant groups to find compatible swaps

        - **Product Enrichment**: Includes product details (title, price,
        images)


        **How Swap Rules Work:**

        1. Merchant configures swap rules defining which products can substitute
        others

        2. Rules are organized by variant groups (e.g., coffee roasts, tea
        flavors)

        3. Each rule specifies "from" variants and "to" variants

        4. Rules can be limited to specific subscription frequencies or all
        orders

        5. Members can swap products within the allowed groups


        **Request Structure:**

        - **Variant Quantity List**: Array of variant IDs with quantities

        - Each entry contains variant ID and quantity

        - System finds swap options for all provided variants


        **Response Structure:**

        - Returns nested list of swap options (up to 5 levels)

        - Level 0: Original variants (as provided in request)

        - Levels 1-4: Progressive swap suggestions

        - Each level contains variant IDs, quantities, titles, prices, images

        - Variants appear with full Shopify product data


        **Use Cases:**

        - Display product swap options in customer portal

        - Allow members to switch between flavor/size variants

        - Build custom product selection interfaces

        - Enable seasonal product swaps (summer/winter varieties)

        - Offer alternative products when items are out of stock

        - Let members customize subscriptions within allowed product groups


        **Example Scenario:**

        Member has "Dark Roast Coffee (12oz)" in subscription. API returns:

        - Level 0: Dark Roast Coffee 12oz (original)

        - Level 1: Medium Roast Coffee 12oz, Light Roast Coffee 12oz

        - Level 2: Dark Roast Coffee 16oz, Decaf Dark Roast 12oz

        - Level 3: Espresso Blend 12oz, French Roast 12oz

        - Level 4: Additional variants based on swap rules


        **Authentication:** Requires API key authentication via X-API-Key header
        or api_key parameter
      operationId: getProductSwapsByVariantIdV2
      parameters:
        - description: API Key (Deprecated - Use Header X-API-Key instead)
          in: query
          name: api_key
          required: false
          schema:
            type: string
        - description: >-
            API Key for authentication (Preferred method - use this instead of
            api_key parameter)
          in: header
          name: X-API-Key
          required: false
          schema:
            type: string
      requestBody:
        content:
          application/json:
            example:
              variantQuantityList:
                - quantity: 2
                  variantId: 123456
                - quantity: 1
                  variantId: 789012
            schema:
              $ref: '#/components/schemas/VariantQuantityInfo'
        description: List of variants with quantities to find swap options for
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                description: >-
                  Nested list where each element is a list of variant options
                  for that swap level
                type: array
          description: >-
            Swap options successfully retrieved with up to 5 levels of
            suggestions
        '400':
          content:
            '*/*':
              schema:
                items:
                  items:
                    $ref: '#/components/schemas/VariantQuantity'
                  type: array
                type: array
          description: Invalid variant information provided
        '401':
          content:
            '*/*':
              schema:
                items:
                  items:
                    $ref: '#/components/schemas/VariantQuantity'
                  type: array
                type: array
          description: Authentication required - invalid or missing API key
        '404':
          content:
            '*/*':
              schema:
                items:
                  items:
                    $ref: '#/components/schemas/VariantQuantity'
                  type: array
                type: array
          description: No swap rules configured for shop
components:
  schemas:
    VariantQuantityInfo:
      properties:
        variantQuantityList:
          items:
            $ref: '#/components/schemas/VariantQuantity'
          type: array
      type: object
    VariantQuantity:
      properties:
        image:
          type: string
        productId:
          type: string
        productTitle:
          type: string
        quantity:
          format: int32
          type: integer
        sellingPlanId:
          type: string
        title:
          type: string
        variantId:
          format: int64
          type: integer
      type: object

````