Skip to main content
You can give a teammate a goal and a program, then follow it. A teammate’s program changes as you send what you know about them: a training day, a constraint, new equipment or a new schedule. Each change is a revision. A revision says why the program changed, what changed, whether the teammate’s targets are still in reach, and whether the change was applied. You can also read the session planned for today, as planned or rebuilt easier or harder for how the teammate feels. 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.
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.

Set a goal

A goal is what the teammate trains for: a goal type, an optional measurable target and an optional due date. Your organization keeps one goal per teammate; sending it again replaces it. The teammate’s own goals are not read or changed.
200
GET /v1/teammates/{external_id}/goal reads it back, and answers 404 not_found when you have set none. Setting a goal needs programs:write; reading it needs programs:read.

Create a program

A program is built as a job. Send the schedule; the goal is the one you set, or the goal you send in the same call.
The answer is 202 with the job:
202
A program your organization creates never replaces one the teammate or their coach made: it is saved, and the teammate chooses in their app.

Poll the job

200
status moves from queued to running, then to succeeded or failed. Poll every few seconds; a program usually takes under a minute. A job is readable with a key of the organization and mode that created it, and answers 404 after the teammate left. A failed job’s error.code is one of:

A teammate with a coach

When the teammate has a coach, the program is saved and not started. It waits as a proposal whose cause kind is created, and proposal.created fires. When the coach accepts it, the program starts and program.revised fires with approval.mode coach. When the coach declines, the program stays saved. See Proposals and coach approval.

Webhooks

A started program fires program.revised with revision 1, a null parent_revision and the cause kind created:
program.revised
A saved or failed job sends no event; poll the job. Programs created through the API are not yet re-planned from the events you send; their revisions list stays empty until they are.

Errors

List a teammate’s programs

GET /v1/teammates/{external_id}/programs lists the teammate’s programs, newest first, so you can find the id the reads below need.
200
status is active, saved, waiting_for_coach or completed. created_by is organization when your organization created it in this mode, else teammate or coach. weekly_sessions is the number of sessions planned in the first week. revision is the latest recorded revision, or null when none is recorded yet. No week or session content is listed: read revisions and today’s session for that.

Reading a program

Both need a key with the programs:read scope. After the teammate claims their account, they also need to allow programs; until then, your organization can read what it sent for them.

Revisions

200
A page holds 1 to 100 revisions (limit, default 20). When next_cursor is not null, pass it as cursor to read the next page. Revision 1 is the program as it was created and has no diff.

Causes

cause.kind says why the program changed. cause.summary says it in a sentence you can show. cause.event_ids are the ids of the events you sent that caused it, as sending events returned them. week_number counts from 1 and day_index is the weekday, 0 for Monday to 6 for Sunday.

Diffs

diff says what changed from from_week and from_day on; earlier days never change. weeks_changed lists every week with any change, sessions_added and sessions_removed count sessions, and changes lists each movement that was swapped, added (before is null) or removed (after is null). A movement id is the id the movement catalog uses. A session_id names the session as it is planned now, in the form {weekly_plan_id}:{session_index}. It is the id to send as session.planned_session_id when you log sets against that session. It is null when that day has no session now.

Targets

feasibility has one entry per target the teammate set. feasible is true when the program is on course to reach the target, false when it is likely out of reach, and null while there is not enough training logged to say. projected_final is where the target is expected to land, and shortfall how far short of the target that is.

Approval

A change waits for the coach only when the teammate has an active coach and the change alters a session; see Proposals and coach approval. A declined or replaced change keeps its revision number, and the next change can use the same number, so two revisions can share one.

Today’s session

200
date is today in the teammate’s time zone: the one the teammate set after they claimed their account, else the timezone you set for them, else UTC. The session is the one scheduled for that date on the teammate’s active program. When nothing is scheduled today, session is null and next_session_date is the next date that has one. A program the teammate works through at their own pace has no dates, so it has no session today and no next date. effort chooses the version: An easier or harder version is built when you ask and is not stored: the program does not change, and the next read as planned returns the stored session. Building it can take a few seconds. When it cannot be built right now, the answer is 503 engine_unavailable; try again shortly. effort_target is the planned effort on a scale of 1 to 10, where 10 is the most a teammate could do.