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

# Proposals and coach approval

> When a program change waits for the teammate's coach, who can decide, and what each decision does.

When the events you send change a teammate's program, the change applies at once, unless the
teammate has a coach. Then the change waits as a **proposal** until one of the teammate's
coaches accepts or declines it. Your organization hears about it either way.

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.

```bash curl theme={null}
curl -X POST "$TF_API_BASE/v1/proposals/5b0e3d2c-8a7f-4e61-9c3b-2d1f0e9a8b7c/accept" \
  -H "X-API-Key: $TF_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"coach_id": "c4a1e8f2-6b3d-4e9a-8f17-2d5c9b0a3e61"}'
```

```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 proposal = await tf.POST('/v1/proposals/{proposal_id}/accept', {
  params: { path: { proposal_id: '5b0e3d2c-8a7f-4e61-9c3b-2d1f0e9a8b7c' } },
  body: { coach_id: 'c4a1e8f2-6b3d-4e9a-8f17-2d5c9b0a3e61' },
});
console.log(proposal.status, proposal.decided_at);
```

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

proposal = tf.accept_proposal("5b0e3d2c-8a7f-4e61-9c3b-2d1f0e9a8b7c", {"coach_id": "c4a1e8f2-6b3d-4e9a-8f17-2d5c9b0a3e61"})
print(proposal["status"], proposal["decided_at"])
```

```json 200 theme={null}
{
  "id": "5b0e3d2c-8a7f-4e61-9c3b-2d1f0e9a8b7c",
  "teammate": "member-1042",
  "program_id": "0f9e8d7c-6b5a-4c3d-8e2f-1a0b9c8d7e6f",
  "status": "accepted",
  "base_revision": 4,
  "cause": {
    "kind": "constraint",
    "summary": "A left knee constraint was reported.",
    "event_ids": ["7c6d5e4f-3a2b-4c1d-9e8f-7a6b5c4d3e2f"]
  },
  "diff": {
    "from_week": 3,
    "from_day": 2,
    "summary": "Week 3 trains around the knee.",
    "weeks_changed": [3],
    "sessions_added": 0,
    "sessions_removed": 0,
    "changes": [
      {
        "week_number": 3,
        "day_index": 4,
        "session_id": "3f6a1b52-0d1e-4c41-9b0f-6a5b8e2d7c10:2",
        "pattern": "squat",
        "before": { "id": null, "name": "Back Squat" },
        "after": { "id": null, "name": "Box Squat" }
      }
    ]
  },
  "warnings": [],
  "engine_version": "ab5787734209",
  "created_at": "2026-11-18T10:00:00Z",
  "decided_at": "2026-11-18T14:25:00Z",
  "decided_by": "c4a1e8f2-6b3d-4e9a-8f17-2d5c9b0a3e61",
  "decline_reason": null
}
```

```json 409 theme={null}
{
  "error": {
    "code": "conflict",
    "message": "The proposal was already decided or replaced by a newer change.",
    "request_id": "4d1a7c9e2b3f4a5c8e6d0b1a2c3d4e5f",
    "details": { "reason": "proposal_not_pending" }
  }
}
```

## When a change waits

| The teammate | The change | What happens |
| - | - | - |
| Has no active coach | Alters a session | Applies at once. `program.revised` fires with approval mode `automatic`. |
| Has an active coach | Alters a session | Waits as a proposal. The program stays as it is. `proposal.created` fires. |
| Either | Alters no session (facts recorded only) | Applies at once, with no approval. |

A change also applies at once, with approval mode `automatic`, when every coach of the teammate
coaches them through an organization that turned on **Apply program changes automatically**
(see [Add and remove coaches](https://docs.technicallyfit.com/gyms/add-and-remove-coaches.md#coach-controls)).

A teammate "has a coach" when at least one coach holds an active coaching authorization for
them and is allowed to see their training data. A coach who cannot see the program cannot
review it, so that coach does not hold changes back.

Changes come only from events sent with a live key. A test key's events never change a
program, so a test key never sees a proposal: its list is empty and a proposal id answers
`404`.

## Four endpoints

| Endpoint | Scope |
| - | - |
| `GET /v1/teammates/{external_id}/proposals` | `proposals:read` |
| `GET /v1/proposals/{proposal_id}` | `proposals:read` |
| `POST /v1/proposals/{proposal_id}/accept` | `proposals:write` |
| `POST /v1/proposals/{proposal_id}/decline` | `proposals:write` |

After the teammate claims their account, they also need to allow `programs`.

## A proposal

```bash curl theme={null}
curl "$TF_API_BASE/v1/teammates/member-1042/proposals?status=pending" \
  -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/teammates/{external_id}/proposals', {
  params: { path: { external_id: 'member-1042' }, query: { status: 'pending' } },
});
for (const proposal of page.data) console.log(proposal.id, proposal.cause.summary);
```

```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_teammate_proposals("member-1042", status="pending")
for proposal in page["data"]:
    print(proposal["id"], proposal["cause"]["summary"])
```

```json 200 theme={null}
{
  "data": [
    {
      "id": "5b0e3d2c-8a7f-4e61-9c3b-2d1f0e9a8b7c",
      "teammate": "member-1042",
      "program_id": "0f9e8d7c-6b5a-4c3d-8e2f-1a0b9c8d7e6f",
      "status": "pending",
      "base_revision": 4,
      "cause": {
        "kind": "constraint",
        "summary": "A left knee constraint was reported.",
        "event_ids": ["7c6d5e4f-3a2b-4c1d-9e8f-7a6b5c4d3e2f"]
      },
      "diff": {
        "from_week": 3,
        "from_day": 2,
        "summary": "Week 3 trains around the knee.",
        "weeks_changed": [3],
        "sessions_added": 0,
        "sessions_removed": 0,
        "changes": [
          {
            "week_number": 3,
            "day_index": 4,
            "session_id": "3f6a1b52-0d1e-4c41-9b0f-6a5b8e2d7c10:2",
            "pattern": "squat",
            "before": { "id": null, "name": "Back Squat" },
            "after": { "id": null, "name": "Box Squat" }
          }
        ]
      },
      "warnings": [],
      "engine_version": "ab5787734209",
      "created_at": "2026-11-18T10:00:00Z",
      "decided_at": null,
      "decided_by": null,
      "decline_reason": null
    }
  ],
  "next_cursor": null
}
```

`diff` has the same shape as a revision's diff (see
[Programs and revisions](https://docs.technicallyfit.com/guides/programs-and-revisions.md)). `base_revision` is the applied
revision the change was computed from.

## Deciding

Send the deciding coach's id. The coach must coach the teammate and be one of your
organization's coaches. Any one of the teammate's coaches may decide; the first decision stands.

To accept:

```bash curl theme={null}
curl -X POST "$TF_API_BASE/v1/proposals/$PROPOSAL_ID/accept" \
  -H "X-API-Key: $TF_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"coach_id": "'"$COACH_ID"'"}'
```

```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 proposalId = process.env.PROPOSAL_ID ?? '';
const coachId = process.env.COACH_ID ?? '';

const accepted = await tf.POST('/v1/proposals/{proposal_id}/accept', {
  params: { path: { proposal_id: proposalId } },
  body: { coach_id: coachId },
});
console.log(accepted.status);
```

```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"))
proposal_id = os.environ["PROPOSAL_ID"]
coach_id = os.environ["COACH_ID"]

accepted = tf.accept_proposal(proposal_id, {"coach_id": coach_id})
print(accepted["status"])
```

To decline, with an optional reason:

```bash curl theme={null}
curl -X POST "$TF_API_BASE/v1/proposals/$PROPOSAL_ID/decline" \
  -H "X-API-Key: $TF_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"coach_id": "'"$COACH_ID"'", "reason": "Not this week."}'
```

```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 declined = await tf.POST('/v1/proposals/{proposal_id}/decline', {
  params: { path: { proposal_id: process.env.PROPOSAL_ID ?? '' } },
  body: { coach_id: process.env.COACH_ID ?? '', reason: 'Not this week.' },
});
console.log(declined.status, declined.decline_reason);
```

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

declined = tf.decline_proposal(os.environ["PROPOSAL_ID"], {"coach_id": os.environ["COACH_ID"], "reason": "Not this week."})
print(declined["status"], declined["decline_reason"])
```

Both answer the proposal with its new `status`, `decided_at` and `decided_by`.

| Answer | When |
| - | - |
| `403 forbidden` | The key does not have the scope, or the coach does not coach the teammate or is not one of your coaches. |
| `403 consent_required` | The teammate claimed their account and has not allowed `programs`. |
| `404 not_found` | Your organization has no teammate this proposal is about, in this key's mode. |
| `409 conflict`, `details.reason` `proposal_not_pending` | The proposal was already accepted, declined or replaced. |
| `409 conflict`, `details.reason` `proposal_stale` | The program changed after the proposal was made (someone edited it). Nothing changes; the next change is computed from the program as it is now. |

## The states of a proposal

| `status` | What happened |
| - | - |
| `pending` | Waits for a coach. The program has not changed. |
| `accepted` | A coach accepted it. The change applied exactly as proposed, and `program.revised` fired with approval mode `coach`. |
| `declined` | A coach declined it. The program did not change. The events behind it stay recorded and are used again the next time the program is re-planned. |
| `superseded` | A newer change replaced it before anyone decided. A program has at most one pending proposal. |

A pending proposal has no expiry: it waits until a coach decides or a newer change replaces
it. If the teammate's last coach stops coaching them while a proposal waits, nobody can decide
it, and the next change applies at once and replaces it.

How a change moves from the events you send to a decision, and the webhook each step sends.

```mermaid theme={null}
flowchart TD
  C["The events you send change a program"] --> Q{"Active coach, and the<br/>change alters a session?"}
  Q -- No --> A["Applies at once<br/>program.revised, approval mode automatic"]
  Q -- Yes --> P["pending<br/>The program stays as it is<br/>proposal.created"]
  P -- "A coach accepts" --> AC["accepted<br/>The change applies exactly as proposed<br/>program.revised, approval mode coach"]
  P -- "A coach declines" --> D["declined<br/>The program does not change<br/>No webhook"]
  P -- "A newer change arrives first" --> S["superseded<br/>No webhook"]
```

Each proposal's revisions appear in the program's revisions with the matching
`approval.status`.

## Webhooks

| Event | When |
| - | - |
| `proposal.created` | A change waits for the coach. |
| `program.revised` | A change applied, automatically or after a coach accepted it. |
| `session.changed` | The applied change altered today's or the next planned session. |
| `feasibility.warning` | The applied change put a target out of reach that was in reach before. |

No event fires when a proposal is declined or replaced; read the proposal to see its state.
See [Webhooks](https://docs.technicallyfit.com/guides/webhooks.md) for delivery and signatures.


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