> ## 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.

# At-risk teammates

> List the teammates whose visits or planned sessions have slipped, and get a webhook when one is flagged.

Once a day TechnicallyFit checks each teammate who allows it and flags the ones who may be about
to stop training: their visits dropped against their own pattern, or they missed several
planned sessions in a row. A flag says why with reason codes. It never carries pain, injury,
body-state or any other health detail.

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/at-risk?location=club-014&limit=50" \
  -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 page = await tf.GET('/v1/insights/at-risk', {
  params: { query: { location: 'club-014', limit: 50 } },
});
for (const flag of page.data) console.log(flag.teammate, flag.reasons);
```

```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"))

page = tf.list_at_risk(location="club-014", limit=50)
for flag in page["data"]:
    print(flag["teammate"], flag["reasons"])
```

```json 200 theme={null}
{
  "data": [
    {
      "teammate": "member-1042",
      "status": "open",
      "reasons": ["visits_dropped"],
      "opened_at": "2026-11-23T06:40:00.000000Z"
    },
    {
      "teammate": "member-2210",
      "status": "nudged",
      "reasons": ["sessions_missed", "visits_dropped"],
      "opened_at": "2026-11-19T06:40:00.000000Z"
    }
  ],
  "next_cursor": null
}
```

## Who can be flagged

Only claimed teammates who allow `at_risk` for your organization are checked, listed or sent in
a webhook. The answer is read again at every request and before every webhook delivery: a
teammate who turns it off, or leaves, disappears from your next request, their flag is deleted
and a queued `teammate.at_risk` delivery is dropped. Placeholders that were never claimed are
never flagged, even when you sent their check-ins yourself. A teammate who joined in the app
and has no id from you is not listed here.

Flagging tells you; it does not tell the teammate. Nothing is sent to them.

## Reasons

| Code | Meaning |
| - | - |
| `visits_dropped` | Over the last two weeks the teammate visited your locations far less than usual: for example, three visits a week for two months, then none for two weeks. Someone who never visited regularly is not flagged for visits. |
| `sessions_missed` | The teammate missed the last few sessions planned in their program, without skipping or moving them. |
| `progress_stalled` | Reserved. Not raised yet. |

The rules use fixed thresholds that are the same for every organization. The check reads only
days that have ended everywhere, so a flag can appear up to two days after the slip. A flag
closes at the first daily check where no reason holds any more, for example when the teammate
is back to their usual visits. More reason codes may be added, so handle one you do not know.

The life of one flag. Only `open` and `nudged` flags are listed, and the webhook is sent only
when a flag opens.

```mermaid theme={null}
flowchart TD
  C["A daily check finds a reason"] --> O["open<br/>teammate.at_risk is sent"]
  O -- "A coach or your staff reach out" --> N["nudged"]
  O -- "A daily check finds no reason" --> X["Closed<br/>No longer listed"]
  N -- "A daily check finds no reason" --> X
  O -. "The teammate turns off at_risk or leaves" .-> D["Deleted<br/>A queued teammate.at_risk is dropped"]
  N -. "The teammate turns off at_risk or leaves" .-> D
```

## List current flags

```bash curl theme={null}
curl "$TF_API_BASE/v1/insights/at-risk?location=club-014" \
  -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 });

// paginate follows next_cursor for you.
for await (const flag of tf.paginate('/v1/insights/at-risk', { params: { query: { location: 'club-014' } } })) {
  console.log(flag.teammate, flag.status, flag.reasons);
}
```

```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"))

# paginate follows next_cursor for you.
for flag in tf.paginate(tf.list_at_risk, location="club-014"):
    print(flag["teammate"], flag["status"], flag["reasons"])
```

| Parameter | Meaning |
| - | - |
| `location` | Your own id for a location. Only teammates whose home location it is are listed. Leave it out for every location. |
| `limit` | 1 to 100, 50 by default. |
| `cursor` | The `next_cursor` of the previous page. |

```json 200 theme={null}
{
  "data": [
    {
      "teammate": "member-1",
      "status": "open",
      "reasons": ["visits_dropped"],
      "opened_at": "2026-11-18T06:40:00.000000Z"
    }
  ],
  "next_cursor": null
}
```

Flags are listed newest first. `teammate` is your own id for the teammate.
`status` is `open`, or `nudged` once the teammate's own coach has opened a conversation with
them from the flag in the console, your staff asked that coach to reach out, or your staff asked
for a fresh program for them (which also appears as a program job of yours). Either way the flag is current until the daily check resolves it.

## The webhook

Subscribe an endpoint to [`teammate.at_risk`](https://docs.technicallyfit.com/guides/webhooks#teammate-at-risk). It is sent once,
when a flag opens, with the teammate id, the reason codes and the time, and nothing else.

```json teammate.at_risk theme={null}
{
  "id": "e2b7c4d1-6f3a-4a9e-8c15-7d2f9b0a3e64",
  "type": "teammate.at_risk",
  "mode": "live",
  "created_at": "2026-11-23T06:41:12.000Z",
  "data": {
    "teammate": "member-1042",
    "reasons": ["visits_dropped"],
    "opened_at": "2026-11-23T06:40:00.000Z"
  }
}
```

## Errors

| Status | Code | When |
| - | - | - |
| 400 | `invalid_request` | The cursor is not one this endpoint gave you. |
| 403 | `forbidden` | The key does not hold `insights:read` (`details.required_scope`). |
| 404 | `not_found` | No location with that id in your organization and mode. |

Requests count toward your key's [rate limits](https://docs.technicallyfit.com/guides/rate-limits.md) like any other.


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