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

# Regenerate subscription widget scripts

> Triggers regeneration and deployment of subscription widget JavaScript files for the authenticated shop. This endpoint rebuilds the widget scripts that power subscription functionality on your storefront and deploys them to CDN.

**What Does This Endpoint Do?**
This endpoint initiates an asynchronous process to regenerate and update the JavaScript files that enable subscription widgets on your store's theme. The widget scripts handle:
- Subscription product selection and display
- Subscription plan offerings on product pages
- Frequency and delivery interval selectors
- Subscription pricing display
- Add-to-cart subscription functionality
- Widget styling and customization

**When to Use This Endpoint:**

**1. After Widget Settings Changes:**
- Modified widget appearance or styling
- Changed subscription plan display options
- Updated widget text or labels
- Altered widget positioning or layout
- Changed frequency options display

**2. After Theme Customization:**
- Installed a new theme
- Updated existing theme
- Made CSS customizations affecting widgets
- Changed theme structure requiring widget updates

**3. After Plan Configuration Changes:**
- Added new subscription plans
- Modified existing plan details
- Changed plan pricing or discounts
- Updated plan availability rules

**4. Troubleshooting:**
- Widget not displaying correctly on storefront
- Subscription options showing outdated information
- Widget functionality broken after theme changes
- Script conflicts or errors on product pages
- Cache issues preventing updates from showing

**5. After App Updates:**
- Appstle subscription app has been upgraded
- New widget features have been released
- Bug fixes requiring script updates

**How It Works:**

1. **Initiation**: API call triggers the script regeneration process
2. **Compilation**: System compiles widget configuration, theme settings, and subscription plans into optimized JavaScript
3. **Deployment**: Generated scripts are uploaded to CDN for fast global delivery
4. **Cache Invalidation**: Old cached versions are invalidated
5. **Completion**: Updated scripts become available to your storefront (typically within 1-2 minutes)

**What Gets Regenerated:**
- **Widget JavaScript**: Core widget functionality and UI components
- **Configuration Data**: Embedded shop-specific settings and plan information
- **Styling Rules**: Custom CSS and theme-specific styles
- **Initialization Code**: Auto-load and widget mounting logic
- **Event Handlers**: Customer interaction and analytics tracking

**Process Details:**
- **Asynchronous**: The regeneration happens in the background
- **Non-blocking**: Endpoint returns immediately (true on success)
- **No downtime**: Existing widgets continue working during regeneration
- **Automatic deployment**: Scripts are automatically deployed to CDN
- **Versioning**: New script versions don't break existing functionality

**Expected Behavior:**
- Endpoint returns `true` immediately to confirm process started
- Script regeneration completes in background (typically 30-90 seconds)
- Updated scripts propagate to CDN (1-2 minutes)
- Browser cache may need clearing to see changes immediately
- Changes visible to customers after cache expiration (varies by browser)

**Use Cases:**
- **Automated Deployments**: Include in CI/CD pipeline after theme updates
- **Widget Troubleshooting**: Force refresh when widget issues occur
- **Configuration Sync**: Ensure widgets reflect latest settings after bulk changes
- **Theme Migration**: Update scripts after moving to new theme
- **Testing**: Regenerate scripts after making configuration changes in staging
- **Maintenance**: Periodic regeneration to ensure optimal performance

**Important Notes:**
- Safe to call multiple times (idempotent operation)
- No negative impact on existing subscriptions
- Does not modify theme files directly
- Scripts are hosted on CDN, not in your theme
- Changes apply to all store pages using subscription widgets
- Browser caching may delay visibility of changes to end users

**Best Practices:**
- Call this endpoint after making widget setting changes
- Wait 2-3 minutes before testing changes on storefront
- Clear browser cache when testing to see latest version
- Use in test/staging environment before production
- Avoid calling excessively (once per configuration change is sufficient)
- Monitor widget functionality after regeneration

**Troubleshooting:**
If widgets still don't reflect changes after regeneration:
1. Wait 5 minutes for full CDN propagation
2. Clear browser cache and hard refresh (Ctrl+Shift+R / Cmd+Shift+R)
3. Check browser console for JavaScript errors
4. Verify theme has widget embed code installed
5. Confirm subscription plans are properly configured
6. Test in incognito/private browsing mode

**Integration Workflows:**

**Theme Update Workflow:**
1. Make theme changes
2. Update widget settings if needed
3. Call regenerate-scripts endpoint
4. Wait 2-3 minutes
5. Test widgets on storefront
6. Deploy to production

**Bulk Configuration Update:**
1. Update multiple subscription plans
2. Modify widget appearance settings
3. Call regenerate-scripts once (not after each change)
4. Verify changes propagated correctly

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



## OpenAPI

````yaml /subscription/admin-api-swagger.json get /api/external/v2/theme-settings/regenerate-scripts-for-shop
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/theme-settings/regenerate-scripts-for-shop:
    get:
      tags:
        - Customization
        - Customer Portal
      summary: Regenerate subscription widget scripts
      description: >-
        Triggers regeneration and deployment of subscription widget JavaScript
        files for the authenticated shop. This endpoint rebuilds the widget
        scripts that power subscription functionality on your storefront and
        deploys them to CDN.


        **What Does This Endpoint Do?**

        This endpoint initiates an asynchronous process to regenerate and update
        the JavaScript files that enable subscription widgets on your store's
        theme. The widget scripts handle:

        - Subscription product selection and display

        - Subscription plan offerings on product pages

        - Frequency and delivery interval selectors

        - Subscription pricing display

        - Add-to-cart subscription functionality

        - Widget styling and customization


        **When to Use This Endpoint:**


        **1. After Widget Settings Changes:**

        - Modified widget appearance or styling

        - Changed subscription plan display options

        - Updated widget text or labels

        - Altered widget positioning or layout

        - Changed frequency options display


        **2. After Theme Customization:**

        - Installed a new theme

        - Updated existing theme

        - Made CSS customizations affecting widgets

        - Changed theme structure requiring widget updates


        **3. After Plan Configuration Changes:**

        - Added new subscription plans

        - Modified existing plan details

        - Changed plan pricing or discounts

        - Updated plan availability rules


        **4. Troubleshooting:**

        - Widget not displaying correctly on storefront

        - Subscription options showing outdated information

        - Widget functionality broken after theme changes

        - Script conflicts or errors on product pages

        - Cache issues preventing updates from showing


        **5. After App Updates:**

        - Appstle subscription app has been upgraded

        - New widget features have been released

        - Bug fixes requiring script updates


        **How It Works:**


        1. **Initiation**: API call triggers the script regeneration process

        2. **Compilation**: System compiles widget configuration, theme
        settings, and subscription plans into optimized JavaScript

        3. **Deployment**: Generated scripts are uploaded to CDN for fast global
        delivery

        4. **Cache Invalidation**: Old cached versions are invalidated

        5. **Completion**: Updated scripts become available to your storefront
        (typically within 1-2 minutes)


        **What Gets Regenerated:**

        - **Widget JavaScript**: Core widget functionality and UI components

        - **Configuration Data**: Embedded shop-specific settings and plan
        information

        - **Styling Rules**: Custom CSS and theme-specific styles

        - **Initialization Code**: Auto-load and widget mounting logic

        - **Event Handlers**: Customer interaction and analytics tracking


        **Process Details:**

        - **Asynchronous**: The regeneration happens in the background

        - **Non-blocking**: Endpoint returns immediately (true on success)

        - **No downtime**: Existing widgets continue working during regeneration

        - **Automatic deployment**: Scripts are automatically deployed to CDN

        - **Versioning**: New script versions don't break existing functionality


        **Expected Behavior:**

        - Endpoint returns `true` immediately to confirm process started

        - Script regeneration completes in background (typically 30-90 seconds)

        - Updated scripts propagate to CDN (1-2 minutes)

        - Browser cache may need clearing to see changes immediately

        - Changes visible to customers after cache expiration (varies by
        browser)


        **Use Cases:**

        - **Automated Deployments**: Include in CI/CD pipeline after theme
        updates

        - **Widget Troubleshooting**: Force refresh when widget issues occur

        - **Configuration Sync**: Ensure widgets reflect latest settings after
        bulk changes

        - **Theme Migration**: Update scripts after moving to new theme

        - **Testing**: Regenerate scripts after making configuration changes in
        staging

        - **Maintenance**: Periodic regeneration to ensure optimal performance


        **Important Notes:**

        - Safe to call multiple times (idempotent operation)

        - No negative impact on existing subscriptions

        - Does not modify theme files directly

        - Scripts are hosted on CDN, not in your theme

        - Changes apply to all store pages using subscription widgets

        - Browser caching may delay visibility of changes to end users


        **Best Practices:**

        - Call this endpoint after making widget setting changes

        - Wait 2-3 minutes before testing changes on storefront

        - Clear browser cache when testing to see latest version

        - Use in test/staging environment before production

        - Avoid calling excessively (once per configuration change is
        sufficient)

        - Monitor widget functionality after regeneration


        **Troubleshooting:**

        If widgets still don't reflect changes after regeneration:

        1. Wait 5 minutes for full CDN propagation

        2. Clear browser cache and hard refresh (Ctrl+Shift+R / Cmd+Shift+R)

        3. Check browser console for JavaScript errors

        4. Verify theme has widget embed code installed

        5. Confirm subscription plans are properly configured

        6. Test in incognito/private browsing mode


        **Integration Workflows:**


        **Theme Update Workflow:**

        1. Make theme changes

        2. Update widget settings if needed

        3. Call regenerate-scripts endpoint

        4. Wait 2-3 minutes

        5. Test widgets on storefront

        6. Deploy to production


        **Bulk Configuration Update:**

        1. Update multiple subscription plans

        2. Modify widget appearance settings

        3. Call regenerate-scripts once (not after each change)

        4. Verify changes propagated correctly


        **Authentication:** Requires valid API key via api_key parameter or
        X-API-Key header
      operationId: regenerateScriptForShop
      parameters:
        - 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
      responses:
        '200':
          content:
            application/json:
              examples:
                Success Response:
                  description: Success Response
                  value: true
              schema:
                type: boolean
          description: >-
            Script regeneration initiated successfully. Returns true to confirm
            the process has started. Scripts will be regenerated asynchronously
            in the background and deployed to CDN within 1-2 minutes.
        '400':
          content:
            application/json:
              example:
                detail: Shop theme settings are not properly configured
                status: 400
                title: Invalid configuration
                type: https://example.com/errors/bad-request
          description: >-
            Bad request - Invalid shop configuration or missing required
            settings
        '401':
          content:
            application/json:
              example:
                detail: >-
                  Valid API key is required. Provide via api_key parameter or
                  X-API-Key header.
                status: 401
                title: Authentication required
                type: https://example.com/errors/unauthorized
          description: Authentication required - Missing or invalid API key
        '403':
          content:
            application/json:
              example:
                detail: API key does not have permission to regenerate theme scripts
                status: 403
                title: Insufficient permissions
                type: https://example.com/errors/forbidden
          description: Insufficient permissions to regenerate scripts
        '429':
          content:
            application/json:
              example:
                detail: >-
                  Too many script regeneration requests. Please wait before
                  trying again.
                retryAfter: 60
                status: 429
                title: Rate limit exceeded
                type: https://example.com/errors/rate-limit
          description: Rate limit exceeded - Too many regeneration requests
        '500':
          content:
            application/json:
              example:
                detail: >-
                  Unable to initiate script regeneration process. Please try
                  again or contact support.
                status: 500
                title: Script regeneration failed
                type: https://example.com/errors/internal-error
          description: Internal server error - Script regeneration failed to initiate

````