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 exampleGET /v1/teammates/@me. Any other teammate id answers404. - 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/@mereturns asaccount_url. A403 consent_requiredanswer to a teammate token carries the same address indetails.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.
TeammateToken, in the API reference.
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.
Read today’s session for the signed-in teammate:
200
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
CallPOST /v1/teammates/@me/sessions/today:start with programs:write on the token
and the teammate’s programs consent item allowed. Send an effort:
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.
- Once today’s session has started, calling it again that day, with any
effort, changes nothing and returns200with the samestarted_atand session. The response’seffortis the one the session started with, not the one you sent. - When no session is scheduled for today, it answers
404 not_found. - When
programsconsent is missing or switched off, it answers403 consent_required. - Calling with any teammate id other than
@meanswers404 not_found.
200
Sending events
OnPOST /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:
200
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.
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
CallGET /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.
curl
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: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:Tokens
5
Call the API as the teammate
Call the API with
Authorization: Bearer <access_token>:Refresh and sign out
An access token lasts one hour. Exchange the refresh token for a new pair before it expires: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 answers401, 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.