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

# Observation builders

> Build pain and soreness reports, logged sets and other readings with the SDKs. Each one is checked against observation/1 and the quantity list before anything is sent.

The builders make the events of [Sending events](https://docs.technicallyfit.com/guides/sending-events.md) for you. Each one
checks what it builds, the same way the API does, so a mistake fails in your code before
any request is sent:

1. **The format.** Required fields, no unknown fields, types, limits, times with an
   offset and the side rules of [Observations](https://docs.technicallyfit.com/guides/observations.md#body-location-and-sides).
2. **The quantity list.** A [listed quantity](https://docs.technicallyfit.com/guides/observations.md#quantities) must use a
   unit it takes, a measure it lists, and a body location when it needs one.

A quantity that is not on the list is not an error: the API keeps it as `not_interpreted`,
and the check reports it as `unknown`. A failed check throws (TypeScript) or raises
(Python) `ObservationValidationError`, whose `issues` list each problem with its path.

You never set `kind` or `status`: the API decides them. `confidence` may be lowered for an
estimate; the API never stores it above your route's default.

## Logged sets and self-reports first

Most organizations send what a teammate did and how they feel. No device is needed.

```ts theme={null}
import { createClient, event, observation } from '@technicallyfit/sdk';

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

const set = event.loggedSet({
  at: '2026-11-17T15:02:00Z',
  route: 'org-floor',
  recordId: 'org-floor:set:91a7',
  movement: { name: 'Back squat' },
  set: { number: 2, reps: 5, load: { value: 225, unit: 'lb' }, effort: 8 },
});

const pain = observation.selfReport({
  quantity: 'pain',
  joint: 'knee',
  side: 'left',
  value: 4,
  at: '2026-11-17T07:30:00Z',
  confidence: 0.8,
  recordId: 'teammate:self-report:5d1e',
});

await tf.events.send('member-1042', [set, event.observation(pain)]);
```

```python theme={null}
import os

from technicallyfit import Client, event, self_report

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

logged = event.logged_set(
    at="2026-11-17T15:02:00Z",
    route="org-floor",
    record_id="org-floor:set:91a7",
    movement={"name": "Back squat"},
    number=2,
    reps=5,
    load={"value": 225, "unit": "lb"},
    effort=8,
)

pain = self_report(
    quantity="pain",
    joint="knee",
    side="left",
    value=4,
    at="2026-11-17T07:30:00Z",
    confidence=0.8,
    record_id="teammate:self-report:5d1e",
)

tf.events.send("member-1042", [logged, event.observation(pain)])
```

A self-report is `pain` or `soreness` on the 0 to 10 scale, from the route `teammate`
unless you name another. Leave `side` out for both sides of a joint that has two, or for a
midline joint.

## Record ids

An observation and a logged set are stored once per `source.route` and
`source.record_id`. Give each one the id your own system already has for it, so the same
reading sent again answers `duplicate`. When you leave a reading's record id out, the
builder makes one; then build each reading once and keep the result.

## Other readings

`observation.measurement` (TypeScript) and `measurement` (Python) build any reading.

```ts theme={null}
import { observation, validateObservation } from '@technicallyfit/sdk';

const sleep = observation.measurement({
  quantity: 'sleep_hours',
  value: 7.25,
  unit: 'h',
  at: '2026-11-16T22:40:00+01:00',
  until: '2026-11-17T06:05:00+01:00',
  route: 'phone-health-store',
  recordId: 'night:2026-11-16',
  confidence: 0.6,
});

console.log(validateObservation(sleep));
```

```python theme={null}
from technicallyfit import ObservationValidationError, measurement

try:
    measurement(
        quantity="set_load",
        value=225,
        unit="lbs",
        at="2026-11-17T15:02:00Z",
        route="org-floor",
        record_id="set-8f2c",
        confidence=0.9,
    )
except ObservationValidationError as error:
    for issue in error.issues:
        print(issue.path, issue.message)
```

The second example fails before anything is sent: `set_load` takes `kg` and `lb`, not
`lbs`.

## Protocol results

Pass a registered `protocol` (such as `sprint_40yd`, `sprint_60yd`, `vertical_jump` or `lift_max`)
and optional `instrument` to `observation.measurement` (TypeScript) or `measurement` (Python). For
a single-quantity registered protocol, the builder fills `quantity`, `measure` and `unit` for you
and refuses a wrong unit or incompatible instrument kind before anything is sent.

```ts theme={null}
import { observation } from '@technicallyfit/sdk';

const sprint = observation.measurement({
  protocol: 'sprint_40yd',
  instrument: 'timing_gates',
  value: 4.62,
  at: '2026-11-27T15:00:00Z',
  route: 'combine-timing',
  recordId: 'combine:40yd:001',
  confidence: 0.9,
});

console.log(sprint.quantity, sprint.unit, sprint.protocol, sprint.instrument);
```

```python theme={null}
from technicallyfit import measurement

sprint = measurement(
    protocol="sprint_40yd",
    instrument="timing_gates",
    value=4.62,
    at="2026-11-27T15:00:00Z",
    route="combine-timing",
    record_id="combine:40yd:001",
    confidence=0.9,
)

print(sprint["quantity"], sprint["unit"], sprint["protocol"], sprint["instrument"])
```

For an owner-defined test, pass `protocol` in `owner:<name>:v<n>` format together with your
`quantity` and `unit`.

## Other events

`event.constraint`, `event.equipmentChange` and `event.scheduleChange` (in Python,
`event.constraint`, `event.equipment_change` and `event.schedule_change`) build the other
event types and give each one an idempotency key when it is built. Keep the event you
built and send that same event again on a retry, so the key stays the same.


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