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:
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:
Security:
Request Parameters:
email (required):
Email Template Configuration:
Template Requirements:
Email Content:
Template Variables:
{customer_name}: Customer’s display name{magic_link}: Portal URL with token{shop_name}: Store name{expiration_time}: Token expiry timeUse Cases:
1. Customer Self-Service:
2. Subscription Management Prompts:
3. Customer Support:
4. Automated Workflows:
5. Marketing Campaigns:
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 Template Disabled:
Email Delivery:
Multiple Subscriptions:
Activity Logging:
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:
Common Errors:
“Customer Email does not exist”:
“Email template not found”:
“Email is currently disabled”:
Authentication: Requires valid X-API-Key header
curl --request GET \
--url https://subscription-admin.appstle.com/api/external/v2/subscription-contracts-email-magic-link"Email triggered successfully."Documentation Index
Fetch the complete documentation index at: https://appstleinc-aeca3e0a.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
curl --request GET \
--url https://subscription-admin.appstle.com/api/external/v2/subscription-contracts-email-magic-link"Email triggered successfully."