Back to KB
Difficulty
Intermediate
Read Time
4 min

`/api/admin/subscriptions` β€” Subscription Analytics Endpoint

By Codcompass TeamΒ·Β·4 min read

/api/admin/subscriptions β€” Subscription Analytics Endpoint

Overview

The /api/admin/subscriptions endpoint provides a real-time aggregation of subscription metrics across the entire user base. Designed primarily for administrative dashboards, internal monitoring tools, and billing reconciliation systems, this route calculates key financial and operational indicators such as Monthly Recurring Revenue (MRR), Annual Recurring Revenue (ARR), active vs. canceled subscription counts, and per-plan breakdowns.

Because subscription data changes frequently and financial metrics require up-to-date accuracy, the endpoint is configured with force-dynamic caching behavior. This ensures that every request bypasses Next.js static generation and fetches fresh data directly from the database. The endpoint is typically invoked when administrators need to audit subscription health, generate periodic reports, or feed metrics into external analytics platforms.

Note on Authentication: While route metadata may indicate public access, the actual implementation enforces strict admin-level session validation. Requests without a valid admin session will be rejected with a 403 Forbidden response.


Endpoint Reference

PropertyValue
Base Path/api/admin/subscriptions
HTTP MethodGET
AuthenticationAdmin Session Required (overrides public metadata)
Cachingforce-dynamic (no caching, real-time)
Content-Typeapplication/json

Request Format

This endpoint does not accept query parameters or a request body. All required data is derived from the authenticated session and the underlying user database.

Headers

| Header | Required | Description

πŸŽ‰ Mid-Year Sale β€” Unlock Full Article

Base plan from just $4.99/mo or $49/yr

Sign in to read the full article and unlock all 635+ tutorials.

Sign In / Register β€” Start Free Trial

7-day free trial Β· Cancel anytime Β· 30-day money-back

Sources

  • β€’ api-reference