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

# Body state

> Read how careful to be with each of a teammate's joints, how recovered it is, and how much is known about it.

Body state is a per-joint summary of one teammate: for every joint and side, how careful to
be with it, how recovered it is from recent training, and how little is known about it. It
works for a teammate with no device at all: their logged training and their known injuries
are enough, and with nothing reported you still get an answer.

> [!WARNING]
>
> Body state is an estimate, not a diagnosis. It does not say what is wrong with
> a joint or whether someone is injured, and it has no injury-risk field. When a
> teammate reports pain, point them to a qualified professional.

Reading body state changes nothing. Body state changes no program unless you turn on the
setting below, and it is off unless you do.

Set these two values once in your terminal. Every example in these docs reads them, so
no example has a host or a key typed into it.

```bash theme={null}
export TF_API_BASE="https://api.technicallyfit.com"
export TF_API_KEY="tf_test_your_key_here"
```

Use a test key (it starts with `tf_test_`) while you build. Never paste a live key into a
page, a ticket or a chat.

## Read a teammate's body state

```bash curl theme={null}
curl "$TF_API_BASE/v1/teammates/member-1042/body-state" \
  -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 state = await tf.GET('/v1/teammates/{external_id}/body-state', {
  params: { path: { external_id: 'member-1042' } },
});
for (const entry of state.joints) {
  console.log(entry.joint, entry.side, entry.caution, entry.uncertainty);
}
```

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

state = tf.get_teammate_body_state("member-1042")
for entry in state["joints"]:
    print(entry["joint"], entry["side"], entry["caution"], entry["uncertainty"])
```

```json 200 theme={null}
{
  "teammate": "member-1042",
  "computed_at": "2026-11-20T09:30:00Z",
  "engine_version": "ab5787734209",
  "joints": [
    {
      "joint": "cervical_spine",
      "side": "midline",
      "caution": 0.0,
      "recovery": 1.0,
      "uncertainty": 1.0
    },
    {
      "joint": "lumbar_spine",
      "side": "midline",
      "caution": 0.0,
      "recovery": 1.0,
      "uncertainty": 1.0
    },
    {
      "joint": "knee",
      "side": "left",
      "caution": 0.31,
      "recovery": 0.86,
      "uncertainty": 0.52
    },
    {
      "joint": "knee",
      "side": "right",
      "caution": 0.05,
      "recovery": 0.86,
      "uncertainty": 0.97
    }
  ]
}
```

```json 403 theme={null}
{
  "error": {
    "code": "consent_required",
    "message": "The teammate has not allowed this.",
    "request_id": "4b1d7c2e9a0f4e6b8c3d5a7f9e1b2c4d",
    "details": { "item": "body_state" }
  }
}
```

The example response is shortened. A real answer lists every joint and side. A `403`
with `consent_required` means the teammate has claimed their account and has not allowed
the `body_state` consent item.

You need a key with the `body_state:read` scope. A teammate who has claimed their account
must have allowed the `body_state` consent item; before the claim you can read it without
one (see [Teammates and ownership](https://docs.technicallyfit.com/guides/teammates-and-ownership.md)).

## The fields

| Field | Meaning |
| - | - |
| `teammate` | Your id for the teammate, as in the path. |
| `computed_at` | When this answer was computed. Each read computes it again, so it moves forward. |
| `engine_version` | The engine release that computed this, as a short code; answers stored earlier may show an older form. |
| `joints` | Every joint and side exactly once, in a fixed order: the midline joints (the spine, ribcage and pelvis) once each with side `midline`, then every limb joint once as `left` and once as `right`. |

Each entry of `joints` has three numbers, each from 0 to 1:

* **`caution`**: how careful to be with this joint. 0 means there is no reason for care. It
  rises with active injuries and limitations at or near the joint.
* **`recovery`**: how recovered the muscles that load this joint are from recent training.
  1 means fully recovered; it falls after hard sessions and comes back with rest.
* **`uncertainty`**: how little is known about this joint. It is 1 when nothing has been
  reported there. A low caution with a high uncertainty means
  "nothing reported", not "known to be fine".

## What feeds it

* **Logged training.** The teammate's working sets from the last few days drive `recovery`.
* **Injuries and limitations** the teammate or their coach recorded drive `caution`.
* **Live pain and soreness reports.** Live `pain` and `soreness` [observations](https://docs.technicallyfit.com/guides/observations.md#what-feeds-body-state) with a joint raise `caution` and lower `uncertainty`.

> [!NOTE]
>
> Only live pain and soreness readings fold into body state. Test-mode readings
> are stored and never change body state.

Device metrics are optional. The estimate belongs to the teammate: it is built from what
every organization they use sends about them, and it leaves with them when they go.

## What moved it

Two ledger endpoints explain what moved a teammate's body state over time. Both use the
`body_state:read` scope and the `body_state` consent item, and page newest first with
`limit` (1 to 100, default 50) and `cursor`:

* `GET /v1/teammates/{external_id}/body-state/changes`: each stored change to the teammate's
  body state, with `computed_at`, `engine_version`, `joints`, and `cause`:
  * `readings`: the update folded at least one new reading. `event_ids` lists only the events
    your organization sent in this mode; other sources are never named.
  * `rebuilt`: no new reading; rebuilt from stored readings after some were removed (for
    example after disconnecting a source route).
  * `other`: no new reading; training, injuries, time or a new engine release moved it.
  * `null` for changes stored before cause tracking was added.
* `GET /v1/teammates/{external_id}/logged-sets`: the sets your organization (and its member
  app) sent, newest first by when they were performed, with `id`, `event_id`, `at`,
  `movement`, `session`, `set` and `source`.

> [!NOTE]
>
> A change is recorded only when a body-state update runs; training sets and injuries do not
> record a snapshot of their own. Neither endpoint returns raw reading values or set measures.
> In test mode, both endpoints return what is recorded for the test teammate, which is empty
> because test-mode readings and sets never write to live body state or training history.

```bash curl theme={null}
curl "$TF_API_BASE/v1/teammates/member-1042/body-state/changes?limit=10" \
  -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 changes = await tf.GET('/v1/teammates/{external_id}/body-state/changes', {
  params: { path: { external_id: 'member-1042' }, query: { limit: 10 } },
});
const sets = await tf.GET('/v1/teammates/{external_id}/logged-sets', {
  params: { path: { external_id: 'member-1042' }, query: { limit: 10 } },
});
console.log(changes.data.length, sets.data.length);
```

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

changes = tf.list_teammate_body_state_changes("member-1042", limit=10)
sets = tf.list_teammate_logged_sets("member-1042", limit=10)
print(len(changes["data"]), len(sets["data"]))
```

## Letting the planner act on body state

By default the planner never changes a program because of body state. A setting lets it: with
the setting on, a change in a teammate's body state can change the rest of their program, the
same way an injury you send does.

> [!WARNING]
>
> Today turning the setting on has no visible effect. Three things have to land
> first: the engine step that re-plans a program from body state, programs
> keeping the plan the engine re-plans from, and a review of the thresholds that
> turn body state into a caution. Until then the setting is stored and read
> back, and no program changes because of it. This page will say when it takes
> effect.

The setting is off for every organization and every teammate until you turn it on. You can
set it for your organization and override it for one teammate:

1. **The teammate's own value**, when you set one (`true` or `false`), wins.
2. Otherwise **your organization's value**.
3. Otherwise it is **off**.

Every read says which of the three decided it, in `source`: `teammate`, `organization` or
`default`.

A teammate who belongs to several organizations gets one answer for their programs: an
explicit off from any of them wins (a teammate value of `false`, or an organization value of
`false` with no teammate value); otherwise it is on when any organization that the teammate
allows both `programs` and `body_state` has it on. A teammate who leaves your organization
loses the value you set for them.

### Your organization's setting

```bash curl theme={null}
curl -X PATCH "$TF_API_BASE/v1/organization/settings" \
  -H "X-API-Key: $TF_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"body_state_planner": true}'
```

```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 settings = await tf.PATCH('/v1/organization/settings', {
  body: { body_state_planner: true },
});
console.log(settings.body_state_planner);
```

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

settings = tf.update_organization_settings({"body_state_planner": True})
print(settings["body_state_planner"])
```

```json 200 theme={null}
{ "body_state_planner": true }
```

Read it with `GET /v1/organization/settings`. Reading needs the `teammates:read` scope and
changing it needs `teammates:write`.

### One teammate's setting

```bash curl theme={null}
curl -X PATCH "$TF_API_BASE/v1/teammates/member-1042/settings" \
  -H "X-API-Key: $TF_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"body_state_planner": false}'
```

```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 settings = await tf.PATCH('/v1/teammates/{external_id}/settings', {
  params: { path: { external_id: 'member-1042' } },
  body: { body_state_planner: false },
});
console.log(settings.body_state_planner?.effective);
```

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

settings = tf.update_teammate_settings("member-1042", {"body_state_planner": False})
print(settings["body_state_planner"]["effective"])
```

```json 200 theme={null}
{
  "body_state_planner": {
    "value": false,
    "effective": false,
    "source": "teammate"
  }
}
```

Send `null` to remove the teammate's own value, so they follow your organization's again.
`effective` is the value in force for this teammate in your organization. Read it with
`GET /v1/teammates/{external_id}/settings`. The same scopes apply, and a teammate who has
claimed their account must have allowed the `body_state` consent item. Only your
organization sets this value; a member app's teammate token cannot.

### What a change looks like

With the setting on, a change in body state that asks for more or less caution at a joint
re-plans the rest of the program from that day. The change is a [revision](https://docs.technicallyfit.com/guides/programs-and-revisions.md)
whose cause kind is `body_state` and whose summary names each joint and side, for example
`week 2 Tue: body state caution on: left knee (moderate)`. A teammate with a coach gets a
[proposal](https://docs.technicallyfit.com/guides/proposals-and-coach-approval.md) instead, and nothing changes until the coach accepts it.

Turning the setting off stops further changes. Cautions already applied stay in the program
until its next change.

A test key reads and writes your test-mode settings only, and a test-mode setting never
affects a live program. Every change at either level is recorded with the key that made it.

## Errors

| Status | Code | When |
| - | - | - |
| `403` | `forbidden` | The key lacks the scope the route needs. `details.required_scope` names it. |
| `422` | `validation_failed` | A settings body has an unknown field or a value that is not a boolean. |
| `403` | `consent_required` | The teammate has claimed their account and has not allowed `body_state`. |
| `404` | `not_found` | Your organization has no such teammate. |

Errors use the shared [error format](https://docs.technicallyfit.com/guides/errors.md).


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