Retrieves comprehensive analytics for a specific subscription contract, including total revenue generated, number of successful orders, and formatted revenue display. This endpoint provides key performance metrics for understanding the financial impact of individual subscriptions.
What This Endpoint Returns: Financial and operational analytics for a single subscription contract, calculated from all successful billing attempts throughout the subscription’s lifetime. Unlike realtime contract queries, this provides historical aggregated data.
Metrics Included:
Revenue Metrics:
Order Count:
Currency Formatting:
Calculation Logic:
Data Source:
SELECT
COUNT(*) as totalOrders,
SUM(order_amount) as totalOrderAmount
FROM subscription_billing_attempt
WHERE shop = ?
AND contract_id = ?
AND status = 'SUCCESS'
What Gets Counted:
Use Cases:
1. Customer Lifetime Value:
2. Subscription Performance:
3. Customer Portal:
4. Reporting & Analytics:
5. Business Intelligence:
Response Format:
{
"totalOrders": 12,
"totalOrderAmount": 599.88,
"totalOrderRevenue": "$599.88"
}
Response Fields:
totalOrders (integer): Count of successful billing attemptstotalOrderAmount (decimal): Numeric revenue totaltotalOrderRevenue (string): Formatted currency displayExample Scenarios:
Brand New Subscription:
{
"totalOrders": 0,
"totalOrderAmount": 0.00,
"totalOrderRevenue": "$0.00"
}
After First Successful Order:
{
"totalOrders": 1,
"totalOrderAmount": 49.99,
"totalOrderRevenue": "$49.99"
}
Established Subscription (EUR):
{
"totalOrders": 24,
"totalOrderAmount": 1199.76,
"totalOrderRevenue": "€1.199,76"
}
Integration Examples:
Customer Portal - Loyalty Display:
const analytics = await fetch(
`/api/external/v2/subscription-contract-details/analytics/${contractId}`,
{ headers: { 'X-API-Key': 'your-key' } }
).then(r => r.json());
const loyaltyMessage = `
<div class="loyalty-badge">
<h3>Thank you for your loyalty!</h3>
<p>You've received ${analytics.totalOrders} orders</p>
<p>Total value: ${analytics.totalOrderRevenue}</p>
</div>
`;
Revenue Dashboard:
// Fetch analytics for multiple subscriptions
const contractIds = [123, 456, 789];
const analyticsPromises = contractIds.map(id =>
getContractAnalytics(id)
);
const allAnalytics = await Promise.all(analyticsPromises);
const totalRevenue = allAnalytics.reduce(
(sum, a) => sum + a.totalOrderAmount, 0
);
console.log(`Total subscription revenue: $${totalRevenue.toFixed(2)}`);
Important Considerations:
Data Accuracy:
Currency Handling:
Performance:
Best Practices:
Limitations:
What’s NOT Included:
Related Calculations:
Average Order Value:
const aov = analytics.totalOrderAmount / analytics.totalOrders;
console.log(`Average order value: $${aov.toFixed(2)}`);
Customer Lifetime Value (projected):
const monthsActive = calculateMonthsActive(contract.createdAt);
const monthlyRevenue = analytics.totalOrderAmount / monthsActive;
const projectedLTV = monthlyRevenue * 12; // Annual LTV
Authentication: Requires valid X-API-Key header
curl --request GET \
--url https://subscription-admin.appstle.com/api/external/v2/subscription-contract-details/analytics/{contractId}{
"totalOrders": 12,
"totalOrderAmount": 599.88,
"totalOrderRevenue": "$599.88"
}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-contract-details/analytics/{contractId}{
"totalOrders": 12,
"totalOrderAmount": 599.88,
"totalOrderRevenue": "$599.88"
}