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

# Sandbox

> Build and test against simulated teammates in test mode on personal or organization workspaces: presets, behaviors, limits, the simulated clock and resets.

> [!NOTE]
>
> Any verified TechnicallyFit account can use the sandbox in test mode (`tf_test_*`) from
> a free personal developer workspace at
> [app.technicallyfit.com/developer](https://app.technicallyfit.com/developer), with no
> organization required.

The sandbox gives you realistic teammates without real people. With a test key from either
a personal developer workspace or an organization workspace, you create simulated teammates
from a few presets, each with a starting history, then advance them one week at a time.
Every simulated week goes through the same event path as your own events, so you can watch
what your integration sees.

```bash curl theme={null}
curl -X POST "$TF_API_BASE/v1/sandbox/teammates" \
  -H "X-API-Key: $TF_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"external_id": "sim-001", "preset": "returning_from_knee_injury", "seed": 42}'
```

```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 created = await tf.POST('/v1/sandbox/teammates', {
  body: { external_id: 'sim-001', preset: 'returning_from_knee_injury', seed: 42 },
});
console.log(created.program_job_id, created.history.events);
```

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

created = tf.create_sandbox_teammate({"external_id": "sim-001", "preset": "returning_from_knee_injury", "seed": 42})
print(created["program_job_id"], created["history"]["events"])
```

```json 201 theme={null}
{
  "teammate": {
    "external_id": "sim-001",
    "simulated": true,
    "preset": "returning_from_knee_injury",
    "seed": 42,
    "weeks_simulated": 0
  },
  "history": {
    "weeks": 6,
    "events": 84,
    "results": { "accepted": 84, "duplicate": 0, "rejected": 0 }
  },
  "program_job_id": "b7e2c4a1-9d3f-4e6b-8a1c-5f7d9e2b4c6a",
  "simulated_now": "2026-11-23T14:30:00.000Z"
}
```

Test mode gives full sandbox access on personal workspaces, including simulated teammates,
test events, programs, body state, proposals and test webhook endpoints. Simulated teammates
live in test mode only. They never mix with live data, never count as live usage, never get
an email or a push notification, and cannot be claimed by a person. Every sandbox endpoint
needs a **test key**: a live key gets `403 forbidden`, and a live key cannot see a
simulated teammate (`404`).

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

## Presets and behaviors

A **preset** is a starting point: a goal, a weekly schedule and a starting history.

| Preset | Starting point | Starting history |
| - | - | - |
| `new_to_training` | General fitness goal, three days a week | One week of logged sets and effort reports |
| `returning_from_knee_injury` | Strength goal, a knee constraint on the left side | Six weeks of logged sets, with knee pain reports that ease over time |
| `endurance_runner` | Endurance goal, two strength days a week, runs outside the program | Eight weeks of logged sets, effort reports and outside workouts |

A **behavior** is how the simulated teammate trains one week.

| Behavior | What happens |
| - | - |
| `on_plan` | Does every planned session as written. |
| `misses_sessions` | Misses some sessions and cuts some sets short, so fewer sets are logged. |
| `finds_it_hard` | Does the work but reports higher effort. |
| `reports_pain` | Does the work and reports pain at a joint, at the preset's injured joint when it has one. |

List them, with their descriptions:

```bash curl theme={null}
# example: sandbox-presets
curl "$TF_API_BASE/v1/sandbox/presets" \
  -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 catalog = await tf.GET('/v1/sandbox/presets');
for (const preset of catalog.presets) console.log(preset.name, preset.history_weeks);
```

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

catalog = tf.list_sandbox_presets()
for preset in catalog["presets"]:
    print(preset["name"], preset["history_weeks"])
```

```json 200 theme={null}
{
  "presets": [
    {
      "name": "new_to_training",
      "description": "New to structured training: a general fitness goal, three days a week, and one week of logged sets and effort reports.",
      "goal": "general_fitness",
      "training_days_per_week": 3,
      "history_weeks": 1
    },
    {
      "name": "returning_from_knee_injury",
      "description": "Coming back from a knee injury on the left side: a strength goal, a knee constraint, and six weeks of logged sets with knee pain reports that ease over time.",
      "goal": "strength",
      "training_days_per_week": 3,
      "history_weeks": 6
    },
    {
      "name": "endurance_runner",
      "description": "A runner: an endurance goal, two strength days a week, runs outside the program, and eight weeks of logged sets, effort reports and outside workouts.",
      "goal": "endurance",
      "training_days_per_week": 2,
      "history_weeks": 8
    }
  ],
  "behaviors": [
    { "name": "on_plan", "description": "Does every planned session as written." },
    { "name": "misses_sessions", "description": "Skips part of the week: some sessions are missed and some sets are cut short." },
    { "name": "finds_it_hard", "description": "Does the work but reports higher effort and drops a rep or two late in sets." },
    { "name": "reports_pain", "description": "Does the work and reports pain at a joint after training, at the injured joint when the preset has one." }
  ]
}
```

## Create a simulated teammate

Send your own `external_id` (up to 64 characters), a preset and an optional `seed`. This
needs the `teammates:write` scope.

```bash curl theme={null}
# example: sandbox-create
curl -X POST "$TF_API_BASE/v1/sandbox/teammates" \
  -H "X-API-Key: $TF_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"external_id": "sim-001", "preset": "returning_from_knee_injury", "seed": 42}'
```

```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 created = await tf.POST('/v1/sandbox/teammates', {
  body: { external_id: 'sim-001', preset: 'returning_from_knee_injury', seed: 42 },
});
console.log(created.program_job_id, created.history.events);
```

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

created = tf.create_sandbox_teammate({"external_id": "sim-001", "preset": "returning_from_knee_injury", "seed": 42})
print(created["program_job_id"], created["history"]["events"])
```

The call creates a test teammate, sends its starting history as events, and starts building
its first program from the preset's goal as a program job. The answer names the job in
`program_job_id`: poll `GET /v1/program-jobs/{job_id}` until it succeeds, then read the
program with `GET /v1/teammates/sim-001/programs`. When the program starts you receive
`program.revised` (revision 1, cause `created`) at your test webhook endpoints.

```json 201 theme={null}
{
  "teammate": {
    "external_id": "sim-001",
    "simulated": true,
    "preset": "returning_from_knee_injury",
    "seed": 42,
    "weeks_simulated": 0
  },
  "history": {
    "weeks": 6,
    "events": 84,
    "results": { "accepted": 84, "duplicate": 0, "rejected": 0 }
  },
  "program_job_id": "b7e2c4a1-9d3f-4e6b-8a1c-5f7d9e2b4c6a",
  "simulated_now": "2026-11-23T14:30:00.000Z"
}
```

Poll the job until `status` is `succeeded` (or `failed`, with an `error`):

```bash curl theme={null}
curl "$TF_API_BASE/v1/program-jobs/b7e2c4a1-9d3f-4e6b-8a1c-5f7d9e2b4c6a" \
  -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 });

let job = await tf.GET('/v1/program-jobs/{job_id}', { params: { path: { job_id: 'b7e2c4a1-9d3f-4e6b-8a1c-5f7d9e2b4c6a' } } });
while (job.status === 'queued' || job.status === 'running') {
  await new Promise((done) => setTimeout(done, 2000));
  job = await tf.GET('/v1/program-jobs/{job_id}', { params: { path: { job_id: job.id } } });
}
console.log(job.status, job.result?.program_id);
```

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

import time

job = tf.get_program_job("b7e2c4a1-9d3f-4e6b-8a1c-5f7d9e2b4c6a")
while job["status"] in ("queued", "running"):
    time.sleep(2)
    job = tf.get_program_job(job["id"])
print(job["status"], job["result"] and job["result"]["program_id"])
```

```json 200 theme={null}
{
  "id": "b7e2c4a1-9d3f-4e6b-8a1c-5f7d9e2b4c6a",
  "teammate": "sim-001",
  "status": "succeeded",
  "result": {
    "outcome": "started",
    "program_id": "3c5e7a9b-1d2f-4a6c-8e0b-2d4f6a8c0e1b",
    "proposal_id": null,
    "engine_version": "ab5787734209",
    "inputs_ignored": []
  },
  "error": null,
  "created_at": "2026-11-23T14:30:00Z",
  "finished_at": "2026-11-23T14:30:07Z"
}
```

Creating is safe to repeat: the same `external_id`, preset and seed answer the same
teammate. Another preset or seed for that `external_id` is `409 conflict`, and so is an
`external_id` you already used for a test teammate you made yourself.

## Simulate a week

Each call generates the next week of events for the behavior you choose and sends them
through the normal event path. This needs the `events:write` scope.

```bash curl theme={null}
# example: sandbox-simulate
curl -X POST "$TF_API_BASE/v1/sandbox/teammates/sim-001/simulate" \
  -H "X-API-Key: $TF_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"behavior": "reports_pain", "seed": 7}'
```

```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 week = await tf.POST('/v1/sandbox/teammates/{simulated_id}/simulate', {
  params: { path: { simulated_id: 'sim-001' } },
  body: { behavior: 'reports_pain', seed: 7 },
});
console.log(week.week.number, week.events.accepted, week.program_id);
```

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

week = tf.simulate_sandbox_week("sim-001", {"behavior": "reports_pain", "seed": 7})
print(week["week"]["number"], week["events"]["accepted"], week["program_id"])
```

The answer says which week was simulated, how many events were `accepted`, `duplicate` or
`rejected`, which program the week followed and the teammate's new simulated time. One call
is one week, so each week can lead to one clear re-plan. Call it again for the next week.

```json 200 theme={null}
{
  "week": { "number": 1, "from": "2026-11-23", "to": "2026-11-29" },
  "events": { "accepted": 21, "duplicate": 0, "rejected": 0 },
  "program_id": "3c5e7a9b-1d2f-4a6c-8e0b-2d4f6a8c0e1b",
  "replan_requested": false,
  "simulated_now": "2026-11-30T06:00:00.000Z"
}
```

A week follows the teammate's active program: its logged sets name the planned sessions and
movements of that week. If the program job has not finished yet, the week follows the
preset's own sessions instead and `program_id` is `null`. Wait for the job to succeed before
you simulate if you want to see the program change.

Simulated events are logged sets and self-reports (session effort, and pain for
`reports_pain`). They use the source route `sandbox` and the device `simulated`. A full week
runs from logged sets and self-reports alone. To add generic device readings (bar velocity on
sets, resting heart rate and sleep duration), send `"include_device_readings": true`.

## Simulated verified records

Send `"include_results": true` on `POST /v1/sandbox/teammates/{simulated_id}/simulate` with a test
key holding `measurements:write` to exercise the full verified-record flow in test mode:

1. Four protocol measurements (40-yard sprint, 60-yard sprint, vertical jump and lift max) are
   ingested through the normal event path using registered protocols and instrument kinds.
2. Two of them are vouched in test mode using TechnicallyFit's test signing key: one as a simulated
   coach witness (level 3) and one as a simulated certifying event (level 4). Each statement names
   a simulated attestor, never a real person or organization.
3. The response includes `results.measurement_ids` and `results.attestation_ids` so you can read
   them via `GET /v1/teammates/{external_id}/measurements` and check them via
   `GET /v1/attestations/{attestation_id}/status` (`valid`).
4. Resetting the teammate or the sandbox erases the simulated measurements through the store so
   subsequent attestation checks answer `withdrawn`.

## Personal workspace limits in the sandbox

Free personal developer workspaces have caps in the sandbox:

* **Active simulated teammates:** Up to **5** active simulated teammates per personal
  workspace. Creating another returns `409 conflict` with
  `details.reason: "sandbox_teammate_limit_reached"`. Reset the sandbox to free slots.
* **Daily engine-heavy writes:** Up to **50** per UTC day across the workspace, counting
  program creations and sandbox week simulations combined. Exceeding the cap returns
  `429 rate_limit_exceeded` with `details.window: "day"`, `details.limit: 50` and a
  `Retry-After` header until midnight UTC.
* **Active test webhook endpoints:** Up to **2** active test webhook endpoints per personal
  workspace (`409 conflict` with `details.reason: "endpoint_limit_reached"` when exceeded).
* **Per-key rate limits:** 30 requests per minute and 14,400 requests per UTC day per key.

See [Rate limits](https://docs.technicallyfit.com/guides/rate-limits.md#personal-workspace-caps) for the full comparison
with Organization plans.

## Repeatable runs

The sandbox is deterministic. The same preset and seed always give the same starting history,
and the same seed and behavior always give the same week, so a test you write today gives the
same events tomorrow. Times are relative to the day the teammate was created. Every simulated
event has a fixed record id, so sending a week again is answered as duplicates.

## The simulated clock

Each simulated teammate has its own clock. It starts when you create the teammate and moves
forward one week with every simulate call, so a simulated week can be later than today. The
program's weeks close on that clock, not on the real date: when you simulate week 2, week 1
is closed and the program can be re-planned from it.

Reads that take today's date, such as `GET /v1/teammates/{external_id}/sessions/today`, use
the real date, not the simulated clock.

## Resets

Reset one simulated teammate to its preset's starting state. Its events, programs and
revisions are removed, and it is created again from the same preset and seed, with a new
clock that starts now.

```bash curl theme={null}
# example: sandbox-reset-one
curl -X POST "$TF_API_BASE/v1/sandbox/teammates/sim-001/reset" \
  -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 reset = await tf.POST('/v1/sandbox/teammates/{simulated_id}/reset', {
  params: { path: { simulated_id: 'sim-001' } },
});
console.log(reset.teammate.weeks_simulated, reset.program_job_id);
```

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

reset = tf.reset_sandbox_teammate("sim-001")
print(reset["teammate"]["weeks_simulated"], reset["program_job_id"])
```

Reset the whole sandbox to remove every test-mode teammate of your workspace, simulated or
made by hand, with their events, programs and revisions. Your keys, webhook endpoints and
locations stay. Resetting twice is safe: the second reset removes nothing.

```bash curl theme={null}
# example: sandbox-reset-all
curl -X POST "$TF_API_BASE/v1/sandbox/reset" \
  -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 result = await tf.POST('/v1/sandbox/reset');
console.log(result.teammates_removed);
```

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

result = tf.reset_sandbox()
print(result["teammates_removed"])
```

```json 200 theme={null}
{ "teammates_removed": 3 }
```

Both resets need the `teammates:write` scope.

## What you will and will not see today

The sandbox stores and returns every simulated event right away. Some later steps are still
being finished on our side, and the sandbox does not pretend otherwise:

* **Re-planning from a simulated week is not switched on yet.** A program re-plans from
  events only once its plan is stored in the form the engine re-plans from, and only while
  re-planning is turned on. Until then `replan_requested` is `false` and no
  `program.revised` follows a simulated week. You still receive `program.revised` when the
  first program starts.
* **The starting history does not shape the first program.** The first program is built from
  the preset's goal and schedule. The history is stored as test-mode events and is read when
  a simulated week is re-planned.
* **Test-mode pain and soreness reports do not change body state.** Live pain and soreness
  readings fold into body state, but test-mode readings never change it; they are stored
  and kept for your sandbox reads.
* **Why a program changed comes from the engine.** A revision's cause names what the engine
  says moved it; the sandbox does not choose it.

## Test on the stack you will go live on

Keys, webhook endpoints and data never move between stacks. If you will go live on a
dedicated stack, build and test with a test key on that stack.


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