# Analytics

Read the calculated metrics the Kaching admin shows, rather than re-deriving them from contracts and webhooks.

https://www.kachingappz.com/developers/subscriptions/analytics/ · Updated 2026-11-23

Read the calculated metrics the Kaching admin shows, rather than re-deriving them from contracts and webhooks.

## Get analytics

```http
GET /shop-api/analytics
```

Permission: **Analytics** → View analytics (`analytics:read`).

Returns the metrics the Kaching admin shows on its **Analytics** and **Billing health** pages — MRR, churn rate, retention, subscription counts and payment success rates — for a preset period or a custom day range.

These are the app's own calculated figures, not raw data to re-derive: the endpoint reads them through the very same services that render those pages, so a number here and the number on the merchant's screen cannot disagree. See [Matching the admin exactly](https://www.kachingappz.com/developers/subscriptions/analytics/#matching-the-admin-exactly) for the three things that most often make them *look* different.

**Query parameters**

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `period` | string | No | `LAST_30_DAYS` | A preset period (below). Ignored when `from` and `to` are given. |
| `from` | string | No | — | First day of a custom range, `YYYY-MM-DD`, read in `tz`. Send together with `to`. |
| `to` | string | No | — | Last day of the range, inclusive. On or after `from`, and not after today in `tz`. |
| `tz` | string | No | the shop's | IANA timezone name, e.g. `America/New_York`. Decides which instants each day covers. |

Accepted `period` values: `TODAY`, `YESTERDAY`, `LAST_24_HOURS`, `LAST_7_DAYS`, `LAST_30_DAYS`, `LAST_90_DAYS`, `LAST_365_DAYS`, `LAST_MONTH` (previous calendar month), `LAST_12_MONTHS`, `LAST_YEAR` (previous calendar year), `ALL_TIME`.

There is no maximum range. `period=CUSTOM` is also accepted alongside `from` and `to`, so a URL copied from the admin's own address bar works unchanged.

**Example**

```bash
curl -G "https://subscriptions.kachingappz.app/shop-api/analytics" \
  -H "Authorization: Bearer <your-api-token>" \
  --data-urlencode "from=2026-09-01" \
  --data-urlencode "to=2026-09-30" \
  --data-urlencode "tz=America/New_York"
```

**Response (200)**

```json
{
  "shop": "example.myshopify.com",
  "currency": "USD",
  "timezone": "America/New_York",
  "period": null,
  "customRange": { "from": "2026-09-01", "to": "2026-09-30" },
  "range": {
    "from": "2026-09-01T04:00:00.000Z",
    "to": "2026-10-01T03:59:59.999Z"
  },
  "failedPaymentsCountAsChurn": false,
  "subscriptions": {
    "activeCount": 259,
    "pausedCount": 17,
    "cancelledCount": 48,
    "newCount": 296,
    "churnedCount": 74,
    "reactivatedCount": 12,
    "netChange": 211,
    "churnRate": 24.71,
    "averageRetentionPeriodDays": 121,
    "averageActiveSubscriptionAgeDays": 197
  },
  "revenue": {
    "mrr": 31916.2,
    "expectedCollectionsNext30Days": 25626.32,
    "upcomingRevenue": [{ "date": "2026-10-16", "revenue": 583.85 }],
    "arpu": 61.33,
    "averageOrderValue": 48.9,
    "averageOrdersPerSubscription": 4.2,
    "averageLifetimeRevenuePerSubscription": 205.4,
    "firstSubscriptionOrdersCount": 96,
    "recurringOrdersCount": 1104,
    "firstSubscriptionOrdersRevenue": 4512.0,
    "recurringOrdersRevenue": 51993.2,
    "totalSubscriptionRevenue": 56505.2,
    "subscriptionTakeRate": 0.31,
    "subscriptionRevenueShare": 0.72
  },
  "billingHealth": {
    "successRate": 94.2,
    "firstTrySuccessRate": 88.1,
    "failureRate": 5.8,
    "perCycleSuccessRate": 97.4,
    "perCycleFirstTrySuccessRate": 90.2,
    "isPerCycleRatePreferred": true,
    "totalBillingAttemptsCount": 1210,
    "successfulBillingAttemptsCount": 1140,
    "failedBillingAttemptsCount": 70,
    "firstTrySuccessCount": 1066,
    "recoveredBillingAttemptsCount": 52,
    "recoveredPaymentsValue": 2480.0,
    "lostBillingAttemptsCount": 18,
    "successCyclesCount": 1140,
    "lostCyclesCount": 31,
    "resolvedCyclesCount": 1171,
    "subscriptionsInDunningCount": 24,
    "failureReasons": {
      "rows": [{ "reason": "insufficient_funds", "count": 31, "percentage": 44.3 }],
      "truncated": false,
      "totalDistinctReasons": 6
    }
  }
}
```

> **Warning** **Every metric can be \`null\`, and \`null\` never means zero.** It means the figure could not be computed for this request — a reader that failed, or a window whose own boundaries were never measured. A shop with genuinely nothing to report returns `0`. Chart `null` as "no data", never as a zero.

### Top-level fields

| Field | Type | Description |
| --- | --- | --- |
| `shop` | string | The shop domain the token belongs to. |
| `currency` | string | The shop's currency. Every money figure is in it. |
| `timezone` | string | The zone the window was read in — your `tz`, or the shop's. |
| `period` | string\|null | The preset read, or `null` when a custom range was. |
| `customRange` | object\|null | `{ from, to }` inclusive days, or `null` when a preset was read. |
| `range` | object | The instants the window actually covers, inclusive, as ISO-8601 UTC. |
| `failedPaymentsCountAsChurn` | boolean | The shop's churn setting — see [below](https://www.kachingappz.com/developers/subscriptions/analytics/#the-failed-payments-setting). |

### subscriptions

| Field | Type | Description |
| --- | --- | --- |
| `activeCount` | number\|null | Subscriptions counted as active **right now** — not over the window. Includes or excludes contracts in dunning per the churn setting. |
| `pausedCount` | number\|null | Contracts currently paused. Now, not over the window. |
| `cancelledCount` | number\|null | Contracts currently cancelled. Now, not over the window. |
| `newCount` | number\|null | Subscriptions that became active during the window, summed per day. One that starts and churns the same day is excluded. |
| `churnedCount` | number\|null | Subscriptions that became inactive during the window, summed per day. One that churns and returns the same day is excluded. |
| `reactivatedCount` | number\|null | Previously inactive subscriptions that became active again during the window. |
| `netChange` | number\|null | Last recorded active count in the window minus the first. Days without a snapshot are skipped, so for a shop younger than the window this spans only the recorded days. |
| `churnRate` | number\|null | Percent 0–100: `(starting + new − ending) / (starting + new)`. **\`null\` unless the window both begins and ends with a recorded snapshot** — see the caution below. |
| `averageRetentionPeriodDays` | number\|null | Average days a subscription stayed active before churning, over those that churned **in the window**. `null` when none did. |
| `averageActiveSubscriptionAgeDays` | number\|null | Average age in days of currently-active subscriptions, from creation to today. |

> **Note** `churnRate` is `null` more often than you might expect, and deliberately so. The rate divides boundary counts against new subscriptions counted across the whole window, so boundaries taken from *inside* the window would report surplus signups as churn. When it is `null`, report the period as unavailable rather than inferring a rate from the other fields.

### revenue

| Field | Type | Description |
| --- | --- | --- |
| `mrr` | number\|null | Monthly Recurring Revenue: every active contract's price normalised to a month. Always active-only. |
| `expectedCollectionsNext30Days` | number\|null | Revenue expected from orders scheduled in the **next 30 days**. Forward-looking: it ignores `period`. |
| `upcomingRevenue` | array\|null | `{ date, revenue }` per upcoming day — the daily breakdown of the figure above. Also ignores `period`. |
| `arpu` | number\|null | Average revenue per unique customer from subscription orders in the **last 30 days**. Ignores `period`. |
| `averageOrderValue` | number\|null | Average value across all subscription orders, initial and recurring. All time. |
| `averageOrdersPerSubscription` | number\|null | Average successful orders per subscription over its lifetime. All time. |
| `averageLifetimeRevenuePerSubscription` | number\|null | Average total revenue per subscription over its lifetime. All time. |
| `firstSubscriptionOrdersCount` | number\|null | Initial orders from subscriptions created during the window. |
| `recurringOrdersCount` | number\|null | Recurring subscription orders during the window. |
| `firstSubscriptionOrdersRevenue` | number\|null | Revenue from those initial orders. |
| `recurringOrdersRevenue` | number\|null | Revenue from those recurring orders. |
| `totalSubscriptionRevenue` | number\|null | The two above added. Includes tax and shipping, subtracts discounts; refunds are **not** subtracted. |
| `subscriptionTakeRate` | number\|null | Ratio 0–1: first-subscription-order revenue against that plus one-time revenue. |
| `subscriptionRevenueShare` | number\|null | Ratio 0–1: all subscription revenue against all revenue. |

The last two are the only figures read from Shopify rather than from Kaching's own records, so they are also the only ones a Shopify rate limit can turn into `null` on its own. Every other field in the response is unaffected when that happens.

### billingHealth

Two readings of the same window, deliberately both returned.

| Field | Type | Description |
| --- | --- | --- |
| `successRate` | number\|null | Percent 0–100, **per attempt**: successful billing attempts over all attempts in the window. |
| `firstTrySuccessRate` | number\|null | Percent 0–100: attempts that succeeded first try, over all attempts. |
| `failureRate` | number\|null | Percent 0–100: failed attempts over all attempts. |
| `perCycleSuccessRate` | number\|null | Percent 0–100, **per cycle**: cycles that ended up paid, over cycles that resolved. Cycles still retrying are in neither. |
| `perCycleFirstTrySuccessRate` | number\|null | Percent 0–100: cycles paid on the first attempt, over resolved cycles. |
| `isPerCycleRatePreferred` | boolean | Which of the two bases the merchant's own Billing health page is currently showing. |
| `totalBillingAttemptsCount` | number\|null | Billing attempts in the window. |
| `successfulBillingAttemptsCount` | number\|null | Of those, successful. |
| `failedBillingAttemptsCount` | number\|null | Of those, failed. |
| `firstTrySuccessCount` | number\|null | Of those, successful on the first attempt. |
| `recoveredBillingAttemptsCount` | number\|null | Payments that failed and were later recovered by dunning. |
| `recoveredPaymentsValue` | number\|null | Their total value, in `currency`. |
| `lostBillingAttemptsCount` | number\|null | Attempts dunning gave up on. |
| `successCyclesCount` | number\|null | Cycles that resolved into a paid order in the window. |
| `lostCyclesCount` | number\|null | Cycles dunning gave up on, deduplicated. |
| `resolvedCyclesCount` | number\|null | `successCyclesCount + lostCyclesCount` — the per-cycle denominator. |
| `subscriptionsInDunningCount` | number\|null | Subscriptions currently in dunning. Now, not over the window. |
| `failureReasons` | object\|null | `{ rows: [{ reason, count, percentage }], truncated, totalDistinctReasons }` — top 20 reasons by count. |

**Why the two rates differ so much.** Every dunning retry writes its own failure, so a cycle that failed four times and then paid contributes one success and four failures to the per-attempt rate. The harder a shop retries, the worse that rate looks. `perCycleSuccessRate` counts each cycle once, and is usually what a merchant means by "how many of my charges go through".

### The failed-payments setting

Merchants choose, in the Kaching admin under **Settings → General**, whether a subscription whose payment failed and never recovered counts as churned. `failedPaymentsCountAsChurn` reports that choice. It **cannot be overridden per request** — following the saved setting is what keeps these figures equal to the ones on the merchant's screen.

| Setting | What counts as a live subscription |
| --- | --- |
| `false` | Active **and** failed. A failed payment is still in dunning and can recover, so it stays alive. |
| `true` | Active only. A failure never followed by a return to active churns on the day the payment failed. |

Fields that **follow** it: `subscriptions.activeCount`, `averageActiveSubscriptionAgeDays`, `churnRate` and `netChange`.

Fields that **never** follow it: `revenue.mrr` (always active-only), `subscriptions.newCount`, `churnedCount`, `reactivatedCount`, `averageRetentionPeriodDays`, `pausedCount`, `cancelledCount`, and everything under `billingHealth`.

### Caching and rate limits

A successful response is cached for **5 minutes** per shop, window, timezone and setting, and says so:

```http
Cache-Control: private, max-age=300
X-Kaching-Analytics-Cache: hit
```

Changing the failed-payments setting takes effect immediately — it is part of the cache key, not merely reported in the body.

This endpoint carries its own limits in place of the global 60/60s, because one call computes around twenty separate metrics:

| Bucket | Budget | Counts |
| --- | --- | --- |
| Requests | 30 per 60 seconds | Every request. |
| Cold computations | 10 per 300 seconds | Only requests that miss the 5-minute response cache. |

A job polling one window never touches the second budget — after the first call its requests come from cache. The second budget bounds a caller walking many *different* windows. Refusals carry `Retry-After` in seconds.

### Matching the admin exactly

- **Timezone is the usual reason two numbers disagree.** The admin's Analytics page reads the window in the **browser's** timezone; this endpoint defaults to the **shop's**. To reproduce a screen exactly, send the `tz` that browser was in.
- **Some figures ignore \`period\` by design.** `expectedCollectionsNext30Days` and `upcomingRevenue` look 30 days *forward*; `arpu` is always the last 30 days; `averageOrderValue`, `averageOrdersPerSubscription` and `averageLifetimeRevenuePerSubscription` are all-time; and `activeCount`, `pausedCount`, `cancelledCount` and `subscriptionsInDunningCount` are counts of *now*, not of the window.
- **\`ALL\_TIME\` and \`LAST\_24\_HOURS\` have no equivalent in the admin.** Its date filter does not offer them, so those two cannot be compared against a screen. Every other period, and any custom range, can.

### Validation

Unlike the admin — which quietly falls back to "Last 7 days" for a hand-edited URL — this endpoint always tells you when a parameter is wrong, so an integration never books a week's figures as the quarter it asked for.

| Request | Response |
| --- | --- |
| `from` without `to` (or vice versa) | `400 { "error": "from and to must be given together" }` |
| `to` before `from` | `400 { "error": "The start date must be on or before the end date" }` |
| A day that is not a real date | `400 { "error": "Not a real calendar date" }` |
| `to` after today in `tz` | `400 { "error": "to must not be after today (2026-10-15 in UTC)" }` |
| An unknown `period` | `400` listing the accepted values |
| `period=CUSTOM` without both days | `400 { "error": "period=CUSTOM needs both from and to" }` |
| A `tz` that is not an IANA zone | `400 { "error": "tz must be a valid IANA timezone" }` |

A single metric that cannot be read is **not** an error — it comes back as `null` with the rest of the response intact.

---
