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

# Send customer portal magic link via email

> Automatically generates and emails a secure magic link to the customer for accessing their subscription management portal. This is a convenience endpoint that combines token generation and email delivery in a single API call.

**Key Features:**
- **Automated Delivery**: Generates magic link and sends email in one operation
- **Customer Lookup**: Finds customer by email address automatically
- **Branded Emails**: Uses shop's configured email templates and branding
- **Subscription Validation**: Only sends if customer has active subscriptions
- **Time-Limited Links**: Email contains token that expires after configured duration

**Email Contents:**
The sent email typically includes:
- **Magic Link Button**: One-click access to customer portal
- **Link URL**: Full URL with embedded authentication token
- **Expiration Notice**: When the link will expire (e.g., "Valid for 24 hours")
- **Shop Branding**: Store logo, colors, and custom messaging
- **Help Text**: Instructions on how to use the portal

**Workflow:**
1. API receives customer email address
2. System looks up customer in Shopify by email
3. Validates customer has active subscription contracts
4. Generates secure JWT authentication token
5. Constructs magic link URL with token
6. Sends branded email with magic link to customer
7. Returns success confirmation to API caller

**Email Template Customization:**
Email appearance and content can be customized via:
- Shop's email notification settings in admin
- Custom email templates for magic links
- Localization settings for customer's language
- Custom branding (logo, colors, footer)

**Common Use Cases:**
- Customer support: send portal access link to customers over phone/chat
- Automated workflows: trigger magic link emails based on events
- Forgot password alternative: passwordless portal access
- Post-purchase flows: send portal access after first order
- Reactivation campaigns: re-engage paused/cancelled customers
- Customer onboarding: welcome emails with portal access
- Subscription reminders: include portal link in reminder emails

**Integration Example:**
```
GET /api/external/v2/subscription-contracts-email-magic-link?
  email=customer@example.com&
  api_key=your_api_key
```
This sends a magic link email to customer@example.com for portal access.

**Error Handling:**
- If customer not found, returns 400 Bad Request
- If customer has no active subscriptions, returns 400
- If email service fails, returns 500 Internal Server Error
- Invalid email format returns 400 Bad Request

**Email Delivery Notes:**
- Emails are sent asynchronously (may take 1-5 minutes to deliver)
- Check spam folders if customer doesn't receive email
- Respect customer's email preferences and unsubscribe status
- Rate limits may apply to prevent abuse

**Security Considerations:**
- Only send to verified customer email addresses
- Email contains passwordless authentication link
- Links expire after configured duration (default: 24-72 hours)
- Sending to wrong email grants that person subscription access
- Consider email verification before using this endpoint

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



## OpenAPI

````yaml /memberships/admin-api-swagger.json get /api/external/v2/subscription-contracts-email-magic-link
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-contracts-email-magic-link:
    get:
      tags:
        - Membership Contracts
      summary: Send customer portal magic link via email
      description: >-
        Automatically generates and emails a secure magic link to the customer
        for accessing their subscription management portal. This is a
        convenience endpoint that combines token generation and email delivery
        in a single API call.


        **Key Features:**

        - **Automated Delivery**: Generates magic link and sends email in one
        operation

        - **Customer Lookup**: Finds customer by email address automatically

        - **Branded Emails**: Uses shop's configured email templates and
        branding

        - **Subscription Validation**: Only sends if customer has active
        subscriptions

        - **Time-Limited Links**: Email contains token that expires after
        configured duration


        **Email Contents:**

        The sent email typically includes:

        - **Magic Link Button**: One-click access to customer portal

        - **Link URL**: Full URL with embedded authentication token

        - **Expiration Notice**: When the link will expire (e.g., "Valid for 24
        hours")

        - **Shop Branding**: Store logo, colors, and custom messaging

        - **Help Text**: Instructions on how to use the portal


        **Workflow:**

        1. API receives customer email address

        2. System looks up customer in Shopify by email

        3. Validates customer has active subscription contracts

        4. Generates secure JWT authentication token

        5. Constructs magic link URL with token

        6. Sends branded email with magic link to customer

        7. Returns success confirmation to API caller


        **Email Template Customization:**

        Email appearance and content can be customized via:

        - Shop's email notification settings in admin

        - Custom email templates for magic links

        - Localization settings for customer's language

        - Custom branding (logo, colors, footer)


        **Common Use Cases:**

        - Customer support: send portal access link to customers over phone/chat

        - Automated workflows: trigger magic link emails based on events

        - Forgot password alternative: passwordless portal access

        - Post-purchase flows: send portal access after first order

        - Reactivation campaigns: re-engage paused/cancelled customers

        - Customer onboarding: welcome emails with portal access

        - Subscription reminders: include portal link in reminder emails


        **Integration Example:**

        ```

        GET /api/external/v2/subscription-contracts-email-magic-link?
          email=customer@example.com&
          api_key=your_api_key
        ```

        This sends a magic link email to customer@example.com for portal access.


        **Error Handling:**

        - If customer not found, returns 400 Bad Request

        - If customer has no active subscriptions, returns 400

        - If email service fails, returns 500 Internal Server Error

        - Invalid email format returns 400 Bad Request


        **Email Delivery Notes:**

        - Emails are sent asynchronously (may take 1-5 minutes to deliver)

        - Check spam folders if customer doesn't receive email

        - Respect customer's email preferences and unsubscribe status

        - Rate limits may apply to prevent abuse


        **Security Considerations:**

        - Only send to verified customer email addresses

        - Email contains passwordless authentication link

        - Links expire after configured duration (default: 24-72 hours)

        - Sending to wrong email grants that person subscription access

        - Consider email verification before using this endpoint


        **Authentication:** Requires API key authentication via X-API-Key header
        or api_key parameter
      operationId: emailMagicLinkV2
      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
        - description: Customer email address to send magic link to
          example: customer@example.com
          in: query
          name: email
          required: true
          schema:
            type: string
      responses:
        '200':
          content:
            text/plain:
              schema:
                type: string
          description: Magic link email sent successfully to customer
        '400':
          content:
            '*/*':
              schema:
                type: string
          description: >-
            Invalid request - customer email not found or no active
            subscriptions
        '401':
          content:
            '*/*':
              schema:
                type: string
          description: Authentication required - invalid or missing API key
        '500':
          content:
            '*/*':
              schema:
                type: string
          description: Error sending email

````