Skip to content

External APIs (0.0.1)

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.

Languages
Servers
https://subscription-admin.appstle.com

Subscription Management

Core APIs for managing the complete subscription lifecycle including creation, updates, pausing, resuming, and cancellation of subscriptions.

Operations

Subscription Payments

APIs for managing subscription payment methods, processing payments, handling payment retries, and updating billing information.

Operations

Subscription Contracts

APIs for managing subscription contracts including delivery schedules, pricing, order notes, billing cycles, and shipping addresses.

Operations

Subscription Products

APIs for managing products within subscriptions including adding, removing, updating quantities, and swapping products.

Operations

Billing & Payments

APIs for handling billing operations, payment processing, and financial transactions related to subscriptions.

Operations

Subscription Discounts

APIs for managing discounts and promotional codes applied to subscriptions.

Operations

Subscription One-Time Products

APIs for managing one-time add-on products that can be purchased alongside recurring subscription items.

Operations

Subscription Plans

APIs for managing subscription plans, pricing tiers, and plan configurations.

Operations

Build-a-Box & Bundles

APIs for managing customizable product boxes and bundles where customers can select multiple items.

Operations

Product Catalog

APIs for managing the product catalog including product information, variants, and inventory.

Operations

Operations & Settings

APIs for managing operational settings, configurations, and administrative functions.

Operations

Customer Portal

APIs powering the customer-facing portal where subscribers can manage their own subscriptions.

Operations

Regenerate subscription widget scripts

Request

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

Query
api_keystring

API Key (Deprecated - Use Header X-API-Key instead)

Headers
X-API-Keystring
curl -i -X GET \
  'https://subscription-admin.appstle.com/api/external/v2/theme-settings/regenerate-scripts-for-shop?api_key=string' \
  -H 'X-API-Key: string'

Responses

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.

Bodyapplication/json
boolean
Response
application/json
true

Get custom CSS for customer portal

Request

Retrieves the custom CSS styling configuration for the customer portal. This endpoint returns all custom CSS rules that have been configured to customize the appearance, layout, and branding of the subscription customer portal.

What is Custom CSS? Custom CSS allows merchants to fully customize the visual appearance of their customer portal beyond the basic theme settings. This enables complete brand alignment and creates a seamless experience that matches the merchant's main store design.

Custom CSS Capabilities:

  • Layout Customization:

    • Modify page layouts and spacing
    • Adjust grid and flexbox configurations
    • Control responsive breakpoints
    • Customize navigation and sidebars
  • Typography:

    • Custom fonts and font families
    • Font sizes, weights, and line heights
    • Letter spacing and text transforms
    • Heading and paragraph styles
  • Colors and Branding:

    • Brand color palette application
    • Custom background colors and gradients
    • Button and link styling
    • Hover and focus states
    • Border colors and shadows
  • Component Styling:

    • Subscription card appearances
    • Form input styling
    • Button designs and interactions
    • Modal and dialog boxes
    • Navigation menus
    • Product images and thumbnails
  • Advanced Features:

    • CSS animations and transitions
    • Media queries for responsive design
    • Pseudo-elements and pseudo-classes
    • Custom icons using CSS
    • Transform and filter effects

CSS Structure: The returned CSS includes:

  • Global styles for portal-wide consistency
  • Component-specific styles
  • Responsive design rules
  • Theme overrides
  • Custom animations
  • Print styles (optional)

Common CSS Selectors Available:

/* Portal container */
.subscription-portal { }

/* Subscription cards */
.subscription-card { }
.subscription-card-header { }
.subscription-card-body { }

/* Buttons */
.btn-primary { }
.btn-secondary { }
.btn-cancel { }

/* Forms */
.form-control { }
.form-group { }
.form-label { }

/* Navigation */
.portal-nav { }
.nav-item { }

/* Product displays */
.product-item { }
.product-image { }
.product-title { }

Use Cases:

  • Apply custom branding to match main store design
  • Create unique visual experiences for different customer segments
  • Implement seasonal or promotional themes
  • Enhance mobile responsiveness
  • Add accessibility improvements (high contrast, larger fonts)
  • A/B test different portal designs
  • Integrate with design systems
  • Implement dark mode or theme switching

Important Notes:

  • CSS is sanitized for security (XSS prevention)
  • Certain properties may be restricted for security reasons
  • External resources (fonts, images) must use HTTPS
  • CSS is cached for performance - changes may take a few minutes to propagate
  • Invalid CSS syntax is automatically filtered out
  • Some core portal elements have !important styles that cannot be overridden

Best Practices:

  • Use specific selectors to avoid conflicts
  • Test across different browsers and devices
  • Keep CSS organized with comments
  • Use CSS variables for maintainability
  • Minify CSS for production performance
  • Consider accessibility in color choices (WCAG compliance)
  • Provide fallbacks for advanced CSS features

Security Considerations:

  • CSS is sanitized to prevent code injection
  • External URLs are validated
  • JavaScript in CSS is blocked (e.g., expression(), behavior())
  • Data URIs are validated for malicious content

Authentication: Requires valid X-API-Key header

Path
idinteger(int64)required

Id

Query
api_keystring

API Key (Deprecated - Use Header X-API-Key instead)

Headers
X-API-Keystring
curl -i -X GET \
  'https://subscription-admin.appstle.com/api/external/v2/subscription-custom-csses/{id}?api_key=string' \
  -H 'X-API-Key: string'

Responses

Custom CSS successfully retrieved

Bodyapplication/json
idinteger(int64)
shopstringrequired
customCssstring
customerPoratlCSSstring
bundlingCSSstring
bundlingIframeCSSstring
Response
application/json
"{\n \"id\": 12345,\n \"shop\": \"example-shop.myshopify.com\",\n \"customCss\": \"/* Global Portal Styles */\\n\" +\n \".subscription-portal {\\n\" +\n \" font-family: 'Helvetica Neue', Arial, sans-serif;\\n\" +\n \" background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\\n\" +\n \" min-height: 100vh;\\n\" +\n \"}\\n\\n\" +\n \"/* Subscription Cards */\\n\" +\n \".subscription-card {\\n\" +\n \" border-radius: 12px;\\n\" +\n \" box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);\\n\" +\n \" background: white;\\n\" +\n \" padding: 24px;\\n\" +\n \" margin-bottom: 16px;\\n\" +\n \" transition: transform 0.2s ease, box-shadow 0.2s ease;\\n\" +\n \"}\\n\\n\" +\n \".subscription-card:hover {\\n\" +\n \" transform: translateY(-2px);\\n\" +\n \" box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);\\n\" +\n \"}\\n\\n\" +\n \"/* Primary Button Styling */\\n\" +\n \".btn-primary {\\n\" +\n \" background-color: #4A90E2;\\n\" +\n \" border-color: #4A90E2;\\n\" +\n \" color: white;\\n\" +\n \" font-weight: 600;\\n\" +\n \" padding: 12px 24px;\\n\" +\n \" border-radius: 6px;\\n\" +\n \" transition: all 0.3s ease;\\n\" +\n \"}\\n\\n\" +\n \".btn-primary:hover {\\n\" +\n \" background-color: #357ABD;\\n\" +\n \" border-color: #357ABD;\\n\" +\n \" transform: scale(1.02);\\n\" +\n \"}\\n\\n\" +\n \"/* Form Inputs */\\n\" +\n \".form-control {\\n\" +\n \" border: 2px solid #E0E0E0;\\n\" +\n \" border-radius: 6px;\\n\" +\n \" padding: 10px 14px;\\n\" +\n \" font-size: 14px;\\n\" +\n \"}\\n\\n\" +\n \".form-control:focus {\\n\" +\n \" border-color: #4A90E2;\\n\" +\n \" box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);\\n\" +\n \" outline: none;\\n\" +\n \"}\\n\\n\" +\n \"/* Responsive Design */\\n\" +\n \"@media (max-width: 768px) {\\n\" +\n \" .subscription-card {\\n\" +\n \" padding: 16px;\\n\" +\n \" }\\n\" +\n \" .btn-primary {\\n\" +\n \" width: 100%;\\n\" +\n \" }\\n\" +\n \"}\",\n \"enabled\": true,\n \"version\": 2,\n \"lastModified\": \"2024-02-20T14:45:00Z\",\n \"createdAt\": \"2024-01-15T10:30:00Z\",\n \"updatedAt\": \"2024-02-20T14:45:00Z\"\n}"

Send magic link email to customer for portal access

Request

Sends an automated email to a customer containing a secure magic link for accessing their subscription management portal. The email is sent using the shop's configured email template and includes a time-limited authentication token.

What This Endpoint Does:

  1. Validates customer exists and has subscriptions
  2. Generates secure portal access token
  3. Retrieves shop's email template configuration
  4. Sends personalized email with magic link
  5. Logs activity for audit trail

Magic Link Functionality:

What is a Magic Link? A magic link is a special URL containing an encrypted authentication token that allows customers to access their portal without entering a password. Clicking the link automatically logs them in.

Link Contents:

  • Shop's portal URL
  • Encrypted customer token (2-hour expiration)
  • Direct access to subscription management
  • No password required

Security:

  • Token expires in 2 hours
  • Single customer authentication
  • Cannot be used by others
  • Logged for security audit

Request Parameters:

email (required):

  • Customer's email address
  • Must exactly match email in Shopify
  • Customer must have at least one subscription
  • Case-sensitive in some systems

Email Template Configuration:

Template Requirements:

  • Email template must be configured in Appstle settings
  • Template type: SUBSCRIPTION_MANAGEMENT_LINK
  • Template must not be disabled
  • Template includes shop branding and customization

Email Content:

  • Personalized greeting with customer name
  • Clickable magic link button/link
  • Expiration notice (link valid 2 hours)
  • Shop branding and footer
  • Optional custom messaging

Template Variables:

  • {customer_name}: Customer's display name
  • {magic_link}: Portal URL with token
  • {shop_name}: Store name
  • {expiration_time}: Token expiry time

Use Cases:

1. Customer Self-Service:

  • "Forgot password" alternative
  • Quick portal access without account setup
  • Passwordless authentication flow
  • Reduce friction for customers

2. Subscription Management Prompts:

  • "Manage your subscription" emails
  • Pre-billing reminders with management link
  • Post-purchase subscription setup
  • Re-engagement campaigns

3. Customer Support:

  • Send portal access to customers
  • Enable self-service during support interactions
  • Provide instant portal access
  • Reduce support workload

4. Automated Workflows:

  • Payment failure recovery emails
  • Subscription expiration notices
  • Pause/skip reminders
  • Renewal notifications

5. Marketing Campaigns:

  • Subscription feature announcements
  • New product availability
  • Loyalty program invitations
  • Referral program links

Process Flow:

1. API receives email parameter
2. Searches subscription database for customer email
3. If not found → Returns 400 error
4. If found → Retrieves customer subscriptions
5. Sorts subscriptions by status (active first)
6. Checks email template configuration
7. If disabled → Returns 400 error with instructions
8. If enabled → Generates magic link token
9. Prepares email with template
10. Sends email via configured provider
11. Logs activity (source: MERCHANT_EXTERNAL_API)
12. Returns success message

Response Format:

"Email triggered successfully."

Simple string response confirming email queued for delivery.

Important Considerations:

Customer Validation:

  • Email MUST exist in subscription database
  • Customer MUST have at least one subscription
  • Customers without subscriptions cannot receive link
  • Returns error if customer not found

Email Template Disabled:

  • If template disabled in settings: Returns error
  • Error message guides merchant to enable template
  • Path: "More -> Email Settings"
  • Template must be explicitly enabled

Email Delivery:

  • Email sent asynchronously
  • Success response doesn't guarantee delivery
  • Check email logs for delivery confirmation
  • Respects shop's email provider settings

Multiple Subscriptions:

  • If customer has multiple subscriptions: Sorts by status
  • Active subscriptions shown first
  • Link provides access to ALL customer subscriptions
  • Portal displays all contracts

Activity Logging:

  • All magic link emails logged
  • Source: MERCHANT_EXTERNAL_API
  • Includes timestamp and customer
  • Viewable in activity logs

Integration Examples:

Webhook Trigger - Payment Failed:

async function handlePaymentFailure(webhook) {
  const customerEmail = webhook.customer.email;
  
  // Send magic link to customer
  await fetch(
    `/api/external/v2/subscription-contracts-email-magic-link?email=${customerEmail}`,
    { headers: { 'X-API-Key': process.env.APPSTLE_API_KEY } }
  );
  
  console.log(`Magic link sent to ${customerEmail} for payment update`);
}

Customer Support Button:

async function sendPortalAccess(customerEmail) {
  try {
    const response = await fetch(
      `/api/external/v2/subscription-contracts-email-magic-link?email=${encodeURIComponent(customerEmail)}`,
      { 
        headers: { 'X-API-Key': apiKey },
        method: 'GET'
      }
    );
    
    if (response.ok) {
      alert('Portal access email sent to customer!');
    }
  } catch (error) {
    console.error('Failed to send magic link:', error);
  }
}

Best Practices:

  1. Validate Email: Check email format before calling API
  2. Rate Limiting: Don't spam customers - limit frequency
  3. Error Handling: Handle customer not found gracefully
  4. User Feedback: Confirm email sent to user
  5. Test Template: Ensure email template configured and working
  6. Monitor Logs: Check activity logs for delivery issues

Common Errors:

"Customer Email does not exist":

  • Email not found in subscription database
  • Customer has no subscriptions
  • Email may be misspelled

"Email template not found":

  • SUBSCRIPTION_MANAGEMENT_LINK template not configured
  • Contact Appstle support to set up template

"Email is currently disabled":

  • Template disabled in Email Settings
  • Navigate to More -> Email Settings
  • Enable "Subscription Management Link" email

Authentication: Requires valid X-API-Key header

Query
api_keystring

API Key (Deprecated - Use Header X-API-Key instead)

emailstringrequired

Customer email

Headers
X-API-Keystring
curl -i -X GET \
  'https://subscription-admin.appstle.com/api/external/v2/subscription-contracts-email-magic-link?api_key=string&email=string' \
  -H 'X-API-Key: string'

Responses

Email successfully queued for delivery

Bodyapplication/json
string
Response
application/json
"Email triggered successfully."

Customers

APIs for managing customer information, profiles, and account details.

Operations