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

# Member apps

> Sign a teammate in to your own app with a teammate token, so an organization key never ships inside an app.

An organization key reads and writes every teammate of your organization. It belongs on
your server and never inside a mobile app, a browser or any other code that ships to a
person's device. When your own app needs to talk to TechnicallyFit for one person, the
person signs in and your app gets a **teammate token**: a credential for that one
teammate of your organization, nothing more.

```bash curl theme={null}
curl "$TF_API_BASE/v1/teammates/@me" \
  -H "Authorization: Bearer $TF_TEAMMATE_TOKEN"
```

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

// A teammate token from sign-in, never an organization key.
const tf = createClient({ credential: process.env.TF_TEAMMATE_TOKEN ?? '', baseUrl: process.env.TF_API_BASE });

const me = await tf.GET('/v1/teammates/@me');
console.log(me.external_id, me.consent.programs);
```

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

from technicallyfit import Client

# A teammate token from sign-in, never an organization key.
tf = Client(os.environ["TF_TEAMMATE_TOKEN"], base_url=os.environ.get("TF_API_BASE"))

me = tf.get_me()
print(me["external_id"], me["consent"]["programs"])
```

```json 200 theme={null}
{
  "id": "5b8e2d4f-6a1c-4e3b-9d7f-0c2a4e6b8d10",
  "external_id": "member-1042",
  "display_name": "Sam Rivera",
  "status": "claimed",
  "mode": "test",
  "timezone": "America/Chicago",
  "home_location_external_id": "club-014",
  "consent": {
    "programs": true,
    "events": true,
    "body_state": false,
    "program_setup": true,
    "usage_insights": false,
    "at_risk": false
  },
  "account_url": "https://app.technicallyfit.com/teammate/settings#section-connected-organizations"
}
```

## What a teammate token can do

A teammate token is short-lived, belongs to one teammate of one organization, and can be
revoked at any time.

* It addresses its teammate as `@me`, for example `GET /v1/teammates/@me`. Any other
  teammate id answers `404`.
* It never sees more than your organization's key could. What it can do is the overlap of
  its scopes and the teammate's own consent: with a consent item off, the matching call
  answers `403 consent_required`, exactly as it does for your key.
* It never changes consent and never leaves the organization. Those happen on the
  teammate's own account page, whose address `GET /v1/teammates/@me` returns as
  `account_url`. A `403 consent_required` answer to a teammate token carries the same
  address in `details.account_url`, so your app can send the person there.
* Every other route refuses it with `403 forbidden`, including every route that needs an
  organization key.

The operations that accept a teammate token list a second security scheme,
`TeammateToken`, in the API reference.

| Scope | What it unlocks for the signed-in teammate |
| - | - |
| `teammates:read` | Read their own record, and set their time zone and their home location (`home_location_external_id` on `PATCH /v1/teammates/@me`, one of your active locations; see [Locations and equipment](https://docs.technicallyfit.com/guides/locations-and-equipment.md#home-locations)). |
| `events:write` | Send their own logged sets, self-reports and visit check-ins. |
| `measurements:write` | Send their own measurements into their record. |
| `programs:read` | Read their programs, a program's revisions and today's session. |
| `programs:write` | Start today's session (`POST /v1/teammates/@me/sessions/today:start`, as planned; needs the `programs` consent item). Goals and new programs stay with your organization key. |
| `body_state:read` | Nothing yet. Body state stays with your organization key. |
| `locations:read` | Nothing yet. The location reads stay with your organization key. |
| `reference:read` | Nothing yet. Reference reads stay with your organization key. |

A teammate token never holds `teammates:write`, proposals, webhooks, insights or location
writes.

## Calling `/@me` operations

A teammate token calls these operations, always with `@me` in place of the teammate id.
Each needs its scope on the token and the consent item the teammate allowed your
organization when they signed in. Consent is read again on every call.

| Operation | Scope | Consent item |
| - | - | - |
| `GET /v1/teammates/@me` and `PATCH /v1/teammates/@me` | `teammates:read` | None |
| `GET /v1/teammates/@me/programs` | `programs:read` | `programs` |
| `GET /v1/teammates/@me/programs/{program_id}/revisions` | `programs:read` | `programs` |
| `GET /v1/teammates/@me/sessions/today` | `programs:read` | `programs` |
| `POST /v1/teammates/@me/sessions/today:start` | `programs:write` | `programs` |
| `POST /v1/teammates/@me/events` | `events:write` | `events` |

Read today's session for the signed-in teammate:

```bash curl theme={null}
curl "$TF_API_BASE/v1/teammates/@me/sessions/today" \
  -H "Authorization: Bearer $TF_TEAMMATE_TOKEN"
```

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

// A teammate token from sign-in, never an organization key.
const tf = createClient({ credential: process.env.TF_TEAMMATE_TOKEN ?? '', baseUrl: process.env.TF_API_BASE });

const today = await tf.GET('/v1/teammates/{external_id}/sessions/today', {
  params: { path: { external_id: '@me' } },
});
console.log(today.date, today.session?.title);
```

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

from technicallyfit import Client

# A teammate token from sign-in, never an organization key.
tf = Client(os.environ["TF_TEAMMATE_TOKEN"], base_url=os.environ.get("TF_API_BASE"))

today = tf.get_today_session("@me")
print(today["date"], today["session"]["title"] if today["session"] else "rest day")
```

```json 200 theme={null}
{
  "date": "2026-11-18",
  "time_zone": "America/Chicago",
  "effort": "as_planned",
  "program_id": "8c1f3e5a-7b9d-4f2e-a4c6-1e3a5c7e9b20",
  "revision": 3,
  "engine_version": null,
  "session": {
    "id": "wk2-d2",
    "title": "Lower body strength",
    "week_number": 2,
    "day_index": 1,
    "blocks": [
      {
        "movement": {
          "id": "0c1d6b1e-5e0f-4b7a-9a43-2f1c9e3d5a10",
          "name": "Back squat"
        },
        "sets": 4,
        "reps": "5",
        "load": {
          "value": 100,
          "unit": "kg"
        },
        "effort_target": 8,
        "rest_seconds": 180,
        "duration_seconds": null,
        "distance_meters": null,
        "notes": null
      },
      {
        "movement": {
          "id": "3e5f7a9b-1c2d-4e6f-8a0b-2c4d6e8f0a1b",
          "name": "Romanian deadlift"
        },
        "sets": 3,
        "reps": "8",
        "load": {
          "value": 70,
          "unit": "kg"
        },
        "effort_target": 7,
        "rest_seconds": 120,
        "duration_seconds": null,
        "distance_meters": null,
        "notes": null
      }
    ]
  },
  "next_session_date": "2026-11-20"
}
```

`session` is `null` on a day with nothing planned, and `next_session_date` names the next
day that has a session.

### Starting today's session

Call `POST /v1/teammates/@me/sessions/today:start` with `programs:write` on the token
and the teammate's `programs` consent item allowed. Send an `effort`:

| `effort` | What happens |
| - | - |
| `as_planned` (the default, also `{}`) | Starts today's stored session. |
| `easier` | Rebuilds today's session easier, stores it, then starts it. |
| `harder` | Rebuilds today's session harder, stores it, then starts it. |

An easier or harder session is stored, so the teammate's app and every later read of
today's session show the rebuilt session. Rebuilding asks the training engine, so it can
take a few seconds longer than `as_planned`.

```bash theme={null}
curl -X POST "$TF_API_BASE/v1/teammates/@me/sessions/today:start" \
  -H "Authorization: Bearer $TEAMMATE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"effort":"as_planned"}'
```

* Once today's session has started, calling it again that day, with any `effort`, changes
  nothing and returns `200` with the same `started_at` and session. The response's `effort`
  is the one the session started with, not the one you sent.
* When no session is scheduled for today, it answers `404 not_found`.
* When `programs` consent is missing or switched off, it answers `403 consent_required`.
* Calling with any teammate id other than `@me` answers `404 not_found`.

The same call with the SDKs, and its answer:

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

// A teammate token from sign-in, never an organization key.
const tf = createClient({ credential: process.env.TF_TEAMMATE_TOKEN ?? '', baseUrl: process.env.TF_API_BASE });

const started = await tf.POST('/v1/teammates/{external_id}/sessions/today:start', {
  params: { path: { external_id: '@me' } },
  body: { effort: 'as_planned' },
});
console.log(started.started_at, started.session.title);
```

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

from technicallyfit import Client

# A teammate token from sign-in, never an organization key.
tf = Client(os.environ["TF_TEAMMATE_TOKEN"], base_url=os.environ.get("TF_API_BASE"))

started = tf.start_today_session("@me", {"effort": "as_planned"})
print(started["started_at"], started["session"]["title"])
```

```json 200 theme={null}
{
  "date": "2026-11-18",
  "time_zone": "America/Chicago",
  "effort": "as_planned",
  "program_id": "8c1f3e5a-7b9d-4f2e-a4c6-1e3a5c7e9b20",
  "revision": 3,
  "engine_version": null,
  "session": {
    "id": "wk2-d2",
    "title": "Lower body strength",
    "week_number": 2,
    "day_index": 1,
    "blocks": [
      {
        "movement": {
          "id": "0c1d6b1e-5e0f-4b7a-9a43-2f1c9e3d5a10",
          "name": "Back squat"
        },
        "sets": 4,
        "reps": "5",
        "load": {
          "value": 100,
          "unit": "kg"
        },
        "effort_target": 8,
        "rest_seconds": 180,
        "duration_seconds": null,
        "distance_meters": null,
        "notes": null
      },
      {
        "movement": {
          "id": "3e5f7a9b-1c2d-4e6f-8a0b-2c4d6e8f0a1b",
          "name": "Romanian deadlift"
        },
        "sets": 3,
        "reps": "8",
        "load": {
          "value": 70,
          "unit": "kg"
        },
        "effort_target": 7,
        "rest_seconds": 120,
        "duration_seconds": null,
        "distance_meters": null,
        "notes": null
      }
    ]
  },
  "started_at": "2026-11-18T17:32:05Z"
}
```

### Sending events

On `POST /v1/teammates/@me/events` a teammate token sends `logged_set`, `observation`
(self-reports on the `teammate` route only; any other route is rejected with `invalid_event`
on `data.source.route`, tying its route and confidence to `teammate`) and `visit_check_in`
only. Any other type comes back in the results as rejected with `event_type_not_allowed`;
send those from your server with your organization key. Leave `teammate` out of each event,
or send `@me`.

A set and a soreness report from the app go through; a constraint does not, because only
your organization key sends it:

```bash curl theme={null}
curl -X POST "$TF_API_BASE/v1/teammates/@me/events" \
  -H "Authorization: Bearer $TF_TEAMMATE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "events": [
    {
      "type": "logged_set",
      "data": {
        "at": "2026-11-18T17:41:00Z",
        "source": { "route": "org-app", "record_id": "org-app:set:8812-1" },
        "movement": { "id": "0c1d6b1e-5e0f-4b7a-9a43-2f1c9e3d5a10" },
        "set": {
          "number": 1,
          "type": "working",
          "reps": 5,
          "load": { "value": 100, "unit": "kg" },
          "effort": 7
        }
      }
    },
    {
      "type": "observation",
      "data": {
        "schema": "observation/1",
        "quantity": "soreness",
        "value": 3,
        "unit": "score_0_10",
        "at": "2026-11-18T07:15:00Z",
        "body": { "joint": "shoulder" },
        "source": { "route": "teammate", "record_id": "org-app:soreness:8840" },
        "confidence": 1.0
      }
    },
    {
      "type": "constraint",
      "idempotency_key": "org-app-inj-0412",
      "at": "2026-11-18T07:30:00Z",
      "data": {
        "action": "add",
        "joint": "knee",
        "side": "left",
        "constraint_type": "injury",
        "severity": "moderate"
      }
    }
  ]
}'
```

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

// A teammate token from sign-in, never an organization key.
const tf = createClient({ credential: process.env.TF_TEAMMATE_TOKEN ?? '', baseUrl: process.env.TF_API_BASE });

const answer = await tf.POST('/v1/teammates/{external_id}/events', {
  params: { path: { external_id: '@me' } },
  body: {
    events: [
      {
        type: 'logged_set',
        data: {
          at: '2026-11-18T17:41:00Z',
          source: { route: 'org-app', record_id: 'org-app:set:8812-1' },
          movement: { id: '0c1d6b1e-5e0f-4b7a-9a43-2f1c9e3d5a10' },
          set: {
            number: 1,
            type: 'working',
            reps: 5,
            load: { value: 100, unit: 'kg' },
            effort: 7
          }
        }
      },
      {
        type: 'observation',
        data: {
          schema: 'observation/1',
          quantity: 'soreness',
          value: 3,
          unit: 'score_0_10',
          at: '2026-11-18T07:15:00Z',
          body: { joint: 'shoulder' },
          source: { route: 'teammate', record_id: 'org-app:soreness:8840' },
          confidence: 1.0
        }
      },
      {
        type: 'constraint',
        idempotency_key: 'org-app-inj-0412',
        at: '2026-11-18T07:30:00Z',
        data: {
          action: 'add',
          joint: 'knee',
          side: 'left',
          constraint_type: 'injury',
          severity: 'moderate'
        }
      },
    ],
  },
});
console.log(answer.summary);
```

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

from technicallyfit import Client

# A teammate token from sign-in, never an organization key.
tf = Client(os.environ["TF_TEAMMATE_TOKEN"], base_url=os.environ.get("TF_API_BASE"))

answer = tf.send_teammate_events("@me", {
    "events": [
        {
          "type": "logged_set",
          "data": {
            "at": "2026-11-18T17:41:00Z",
            "source": { "route": "org-app", "record_id": "org-app:set:8812-1" },
            "movement": { "id": "0c1d6b1e-5e0f-4b7a-9a43-2f1c9e3d5a10" },
            "set": {
              "number": 1,
              "type": "working",
              "reps": 5,
              "load": { "value": 100, "unit": "kg" },
              "effort": 7
            }
          }
        },
        {
          "type": "observation",
          "data": {
            "schema": "observation/1",
            "quantity": "soreness",
            "value": 3,
            "unit": "score_0_10",
            "at": "2026-11-18T07:15:00Z",
            "body": { "joint": "shoulder" },
            "source": { "route": "teammate", "record_id": "org-app:soreness:8840" },
            "confidence": 1.0
          }
        },
        {
          "type": "constraint",
          "idempotency_key": "org-app-inj-0412",
          "at": "2026-11-18T07:30:00Z",
          "data": {
            "action": "add",
            "joint": "knee",
            "side": "left",
            "constraint_type": "injury",
            "severity": "moderate"
          }
        }
    ]
})
print(answer["summary"])
```

```json 200 theme={null}
{
  "results": [
    {
      "index": 0,
      "status": "accepted",
      "type": "logged_set",
      "event_id": "1f3a5c7e-9b2d-4f6a-8c0e-2a4c6e8a0c12"
    },
    {
      "index": 1,
      "status": "accepted",
      "type": "observation",
      "event_id": "2a4c6e8a-0c1e-4a3b-9d5f-7b9d1f3a5c23",
      "observation": {
        "kind": "joint_level",
        "status": "not_interpreted"
      }
    },
    {
      "index": 2,
      "status": "rejected",
      "type": "constraint",
      "event_id": null,
      "reason": {
        "code": "event_type_not_allowed",
        "field": "type",
        "message": "A member app cannot send this event type. Send it with your organization key."
      }
    }
  ],
  "summary": {
    "accepted": 2,
    "duplicate": 0,
    "rejected": 1
  }
}
```

What a refused call returns:

| Situation | Answer |
| - | - |
| The teammate switched the consent item off, or never allowed it | `403 consent_required`, "The teammate has not allowed this.", with `details.item` and `details.account_url` |
| The token lacks the scope | `403 forbidden`, "API key does not include the required scope." |
| Any teammate id other than `@me` | `404 not_found`, "We could not find that teammate." |
| An operation not in the table above | `403 forbidden`, "A teammate token cannot call this route." |
| The teammate left, or the app or sign-in was revoked | `401`, sign in again |

## Register your app

An owner or admin of your organization registers each app for one mode (test or live),
with:

* a name, shown to the person when they sign in;
* the redirect addresses your app receives the sign-in result on: an https link your app
  has claimed, or a private-use scheme named after your domain such as
  `com.example.gym:/callback`. Loopback http addresses work in test mode only;
* the scopes the app may ask for, from the table above;
* whether a person with no invitation may join your organization while signing in.

Registering gives you a `client_id`. There is no client secret: an app cannot keep one.
Turning an app off signs every teammate out of it at once.

### Reading app configuration before sign-in

Call `GET /v1/app-config?client_id=<your client_id>` on launch to load your organization's
branding and enabled app features before a teammate signs in. This endpoint is public and
takes no API key or teammate token.

It returns your organization's `display_name`, `logo_url`, `primary_color`, `accent_color`,
`support_email`, `gym_handle`, `features` (`programs`, `visit_check_ins` and `coaches`) and
`updated_at`.

```bash curl theme={null}
curl "$TF_API_BASE/v1/app-config?client_id=your-client-id"
```

## Sign a teammate in

Sign-in is the standard OAuth authorization code flow with PKCE. The person signs in on a
page TechnicallyFit hosts, shown with your organization's name, logo and colors.

**1. Make a PKCE pair**

Make a random `code_verifier` and its SHA-256 `code_challenge` (base64url, no padding).

**2. Open the authorization address**

Open the authorization address in the system browser, never in a web view:

```text theme={null}
GET /oauth/authorize?response_type=code
  &client_id=<your client_id>
  &redirect_uri=com.example.gym:/callback
  &scope=teammates:read programs:read
  &state=<random>
  &code_challenge=<code_challenge>
  &code_challenge_method=S256
```

Add `claim=<token>` when the person opened one of your invitation links, so they
claim their account while they sign in.

**3. The person signs in**

The person signs in or signs up, and then:

* if they are already your teammate, they confirm in one step;
* if an invitation came with the sign-in, they claim it and choose what to share;
* if your app allows joining, they join your organization and choose what to share;
* otherwise your app receives `error=access_denied`.

**4. Exchange the code**

Your redirect address receives `code` and your `state`. Check the `state`, then
exchange the code:

```text theme={null}
POST /oauth/token
Content-Type: application/x-www-form-urlencoded

grant_type=authorization_code&client_id=<your client_id>
  &code=<code>&code_verifier=<code_verifier>&redirect_uri=com.example.gym:/callback
```

```json Tokens theme={null}
{
  "access_token": "tf_at_...",
  "refresh_token": "tf_rt_...",
  "token_type": "Bearer",
  "expires_in": 3600,
  "scope": "teammates:read programs:read"
}
```

**5. Call the API as the teammate**

Call the API with `Authorization: Bearer <access_token>`:

```text theme={null}
GET /v1/teammates/@me
Authorization: Bearer tf_at_...
```

Store both tokens in the device's secure storage and never log them.

The [TypeScript](https://docs.technicallyfit.com/sdks/typescript.md#sign-a-teammate-in-from-a-member-app) and
[Python](https://docs.technicallyfit.com/sdks/python.md#sign-a-teammate-in-from-a-member-app) SDKs run these steps for you
and give you a credential that refreshes itself.

```typescript TypeScript theme={null}
import {
  RefreshingTeammateCredential,
  beginTeammateSignIn,
  completeTeammateSignIn,
  createClient,
} from '@technicallyfit/sdk';
import type { TeammateSignInConfig } from '@technicallyfit/sdk';

const signIn: TeammateSignInConfig = {
  issuer: process.env.TF_API_BASE ?? '',
  clientId: 'your-client-id',
  redirectUri: 'com.example.gym:/callback',
  scopes: ['teammates:read', 'programs:read', 'programs:write', 'events:write'],
};

// Steps 1 and 2: open pending.url in the system browser and keep pending until the redirect returns.
// Pass { claim } as the second argument when the person opened one of your invitation links.
const pending = await beginTeammateSignIn(signIn);

// Step 4: your redirect address receives the answer; the SDK checks the state and exchanges the code.
const callbackUrl = 'com.example.gym:/callback?code=...&state=...';
const tokens = await completeTeammateSignIn(signIn, pending, callbackUrl);

// Step 5: call the API as that teammate. New tokens arrive in onTokens: store them securely.
const credential = new RefreshingTeammateCredential(signIn, tokens, {
  onTokens: (next) => console.log('save the new tokens', next.expiresAt),
});
const tf = createClient({ credential, baseUrl: process.env.TF_API_BASE });
const me = await tf.GET('/v1/teammates/@me');
console.log(me.external_id);
```

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

from technicallyfit import (
    Client,
    RefreshingTeammateCredential,
    TeammateSignInConfig,
    begin_teammate_sign_in,
    complete_teammate_sign_in,
)

sign_in = TeammateSignInConfig(
    issuer=os.environ["TF_API_BASE"],
    client_id="your-client-id",
    redirect_uri="com.example.gym:/callback",
    scopes=["teammates:read", "programs:read", "programs:write", "events:write"],
)

# Steps 1 and 2: open pending.url in the system browser and keep pending until the redirect returns.
# Pass claim=... when the person opened one of your invitation links.
pending = begin_teammate_sign_in(sign_in)

# Step 4: your redirect address receives the answer; the SDK checks the state and exchanges the code.
callback_url = "com.example.gym:/callback?code=...&state=..."
tokens = complete_teammate_sign_in(sign_in, pending, callback_url)

# Step 5: call the API as that teammate. New tokens arrive in on_tokens: store them securely.
credential = RefreshingTeammateCredential(sign_in, tokens, on_tokens=lambda fresh: print("save", fresh.expires_at))
tf = Client(credential, base_url=os.environ["TF_API_BASE"])
print(tf.get_me()["external_id"])
```

## Refresh and sign out

An access token lasts one hour. Exchange the refresh token for a new pair before it
expires:

```text theme={null}
POST /oauth/token
Content-Type: application/x-www-form-urlencoded

grant_type=refresh_token&client_id=<your client_id>&refresh_token=<refresh_token>
```

Each refresh returns a new refresh token and retires the old one; a refresh token lasts
30 days from its last use. Refresh one request at a time. Using a retired refresh token
again signs the person out of your app, because it means the token was copied.

To sign out, send `POST /oauth/revoke` with `token=<refresh_token>`. The person can also
sign out of your app from their TechnicallyFit settings.

## When a teammate leaves

A teammate token stops working at once, and the next request answers `401`, when:

* the teammate leaves your organization;
* the teammate deletes their account;
* the person signs out of your app, in your app or in their settings;
* your organization turns the app off.

The refresh token stops working at the same moment. Send the person back to sign-in.


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