> ## Documentation Index
> Fetch the complete documentation index at: https://docs.technicallyfit.com/llms.txt
> Use this file to discover all available pages before exploring further.

# What drives retention

> Read one retention figure, the share of teammates still training at 90 days, and the nine figures under it that move it, for a period and the period before.

What drives retention is one figure, the share of teammates still training 90 days after they
joined, with the things that move it underneath, in a fixed tree that is the same for every
organization. Each metric has a stable key, its parent's key, a plain definition, who it is
counted out of, and its value for the period and for the period before. A metric never carries
pain, injury, body-state or any other health detail, and the tree cannot be edited.

Your key needs `insights:read`. A test key reads test teammates; a live key reads live ones. The
two never mix.

```bash curl theme={null}
curl "$TF_API_BASE/v1/insights/retention?period=90" \
  -H "X-API-Key: $TF_API_KEY"
```

```typescript TypeScript theme={null}
import { createClient } from '@technicallyfit/sdk';

const tf = createClient({ credential: process.env.TF_API_KEY ?? '', baseUrl: process.env.TF_API_BASE });

const retention = await tf.GET('/v1/insights/retention', { params: { query: { period: 90 } } });
for (const metric of retention.data) {
  if (metric.value.withheld) continue;
  console.log(metric.key, metric.parent_key, metric.value.share, metric.previous.share);
}
```

```python Python theme={null}
import os

from technicallyfit import Client

tf = Client(os.environ["TF_API_KEY"], base_url=os.environ.get("TF_API_BASE"))

retention = tf.get_retention(period=90)
for metric in retention["data"]:
    print(metric["key"], metric["parent_key"], metric["value"])
```

```json 200 theme={null}
{
  "location": null,
  "period": 90,
  "from": "2026-08-28",
  "to": "2026-11-25",
  "previous_from": "2026-05-30",
  "previous_to": "2026-08-27",
  "min_group_size": 5,
  "data": [
    {
      "key": "still_training_at_90_days",
      "parent_key": null,
      "definition": "Visited your gym or logged a session at least once in days 61 to 90 after joining (the last 30 of their first 90 days). Counted out of members who joined at least 90 days ago.",
      "denominator": "Out of members whose 90th day after joining fell in the period.",
      "value": { "share": 62, "count": 31, "total": 50, "withheld": false },
      "previous": { "share": 55, "count": 22, "total": 40, "withheld": false },
      "available_on": null
    },
    {
      "key": "came_back_after_a_coach_message",
      "parent_key": "came_back_after_a_nudge",
      "definition": "Slipping members whose first nudge was from their coach (Message or Ask coach) and who visited your gym or logged a session in the 30 days after it.",
      "denominator": "Out of slipping members whose 30 days after a first nudge from their coach ended in the period.",
      "value": { "share": null, "count": null, "total": null, "withheld": true },
      "previous": { "share": 50, "count": 5, "total": 10, "withheld": false },
      "available_on": null
    }
  ]
}
```

## The tree

Each metric is a share: of the teammates in its cohort (`denominator`), `count` did it and
`share` is that in whole percent. A teammate is in a cohort for the period when their window
ended in it, so each teammate is in one period's cohort at most and periods never overlap. Day 1
is the day their current link to your organization began. A visit is a check-in at one of your
locations; a session is one they logged in TechnicallyFit.

| Key | Parent | A teammate counts when they | Out of teammates |
| - | - | - | - |
| `still_training_at_90_days` | none | visited or logged a session on at least one day from day 61 to day 90 | whose day 90 fell in the period |
| `came_back_in_week_one` | `still_training_at_90_days` | visited or logged a session on at least 2 different days in days 1 to 7 | whose day 7 fell in the period |
| `trains_twice_a_week` | `still_training_at_90_days` | visited or logged a session on at least 2 days a week on average over the period (9 days in 30, 26 in 90) | who had joined by the first day of the period |
| `came_back_after_a_nudge` | `still_training_at_90_days` | visited or logged a session in the 30 days after the first nudge on their at-risk flag | flagged, whose 30 days after that nudge ended in the period |
| `visited_within_3_days` | `came_back_in_week_one` | visited on days 1 to 3 | whose day 7 fell in the period |
| `first_session_in_week_one` | `came_back_in_week_one` | logged a session on days 1 to 7 | whose day 7 fell in the period |
| `has_a_program` | `trains_twice_a_week` | logged at least one session from a program in the period | who had joined by the first day of the period |
| `trains_with_a_coach` | `trains_twice_a_week` | were coached by one of your organization's coaches on any day of the period | who had joined by the first day of the period |
| `reached_out_within_7_days` | `came_back_after_a_nudge` | got a nudge on days 1 to 7 of their at-risk flag | flagged, whose flag's day 7 fell in the period |
| `came_back_after_a_coach_message` | `came_back_after_a_nudge` | first nudge was from their coach, and came back in the 30 days after it | flagged, whose 30 days after a first nudge from their coach ended in the period |

A nudge is one your staff sent from the console (Message, Ask coach or Fresh program). Only days
that have ended everywhere are read (up to two days ago). More metrics may be added, so handle a
key you do not know.

| Parameter | Meaning |
| - | - |
| `period` | `30` or `90` (the default): the days ending two days ago (UTC). `previous` is the same number of days just before. |
| `location` | Your own id for a location. Only teammates whose home location it is are counted. Leave it out for every location. |

**Not enough history yet.** `still_training_at_90_days` needs 90 days of your organization's own
data. Until then its `available_on` is the date it first appears (or null while there is no data
at all), its figures are empty, and every other metric still answers.

## Who is counted

A teammate is counted only while they allow `usage_insights` for your organization; the three
metrics built on at-risk flags (`came_back_after_a_nudge`, `reached_out_within_7_days`,
`came_back_after_a_coach_message`) also need `at_risk`. Both are read again at every request: a
teammate who turns one off, or leaves, is gone from your next request.

## Withheld figures

A metric is withheld when the teammates who did it, or those who did not, are 1 to 4
(`min_group_size` is 5, the same for every organization): `share`, `count` and `total` are null
and `withheld` is true. `came_back_after_a_coach_message` is part of `came_back_after_a_nudge`, so
it is also withheld when subtracting it from its parent would leave 1 to 4 teammates: a parent
never gives away a withheld child. When you read one location, a metric is withheld too if the
rest of the organization would be a group of 1 to 4. An empty cohort is `share: null` with
`count: 0`, `total: 0` and `withheld: false`. Withheld never means zero.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.