# 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 Endpoint: GET /api/external/v2/theme-settings/regenerate-scripts-for-shop Version: 0.0.1 ## Query parameters: - `api_key` (string) API Key (Deprecated - Use Header X-API-Key instead) ## Header parameters: - `X-API-Key` (string) ## Response 400 fields ## Response 401 fields ## Response 403 fields ## Response 429 fields ## Response 500 fields