Guide
Assigning programmes
The core of most integrations: put a programme in your library, assign it to customers with days on their weekly schedule, and keep it up to date. Customers find it in the app and on their watch, with nothing to set up.
1. Create a library programme
POST /v1/orgs/{orgId}/programmes, with the programmes:write scope, takes the same body as the portal’s programme editor, plus the two flags.
IDEMPOTENCY_KEY=$(uuidgen) # send the same key again if you retry
curl -X POST https://api.wristworkout.com/v1/orgs/org_id/programmes \
-H "Authorization: Bearer $WW_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $IDEMPOTENCY_KEY" \
-d '{
"name": "Leg Day A",
"watchName": "LEG DAY A",
"unit": "kg",
"stations": [
{
"exerciseId": "g_leg_press",
"sets": [
{ "kind": "warmup", "target": 12, "loadX100": 8000 },
{ "kind": "work", "target": 10, "loadX100": 16000 },
{ "kind": "work", "target": 10, "loadX100": 16000 }
],
"restS": 90,
"note": "seat 4"
},
{
"exerciseId": "g_leg_extension",
"sets": [
{ "kind": "work", "target": 12, "loadX100": 4500 },
{ "kind": "work", "target": 12, "loadX100": 4500 }
],
"restS": 60
}
],
"customerCanCopy": true
}'const url = 'https://api.wristworkout.com/v1/orgs/org_id/programmes';
const res = await fetch(url, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.WW_API_KEY}`,
'Content-Type': 'application/json',
// Keep the key if you retry this request.
'Idempotency-Key': crypto.randomUUID(),
},
body: JSON.stringify({
name: 'Leg Day A',
watchName: 'LEG DAY A',
unit: 'kg',
stations: [
{
exerciseId: 'g_leg_press',
sets: [
{ kind: 'warmup', target: 12, loadX100: 8000 },
{ kind: 'work', target: 10, loadX100: 16000 },
{ kind: 'work', target: 10, loadX100: 16000 },
],
restS: 90,
note: 'seat 4',
},
{
exerciseId: 'g_leg_extension',
sets: [
{ kind: 'work', target: 12, loadX100: 4500 },
{ kind: 'work', target: 12, loadX100: 4500 },
],
restS: 60,
},
],
customerCanCopy: true,
}),
});
const programme = await res.json();- Stations use built-in exercises, whose IDs start with
g_(GET /v1/orgs/{orgId}/exercises?scope=globallists them, withprogrammes:read), and the organisation’s own exercises and machines, which you add withPOST /v1/orgs/{orgId}/exercisesandPOST /v1/orgs/{orgId}/machines. - Loads are whole numbers in hundredths of the programme’s unit:
16000is 160 kg. A set with no external load hasloadX100: null. watchNameis what the watch shows: plain ASCII, at most 16 characters.- Active library programmes count against the plan’s programme allowance: a gym’s own plan, or the plan covering an independent trainer. Past it, a new programme gets 422
LIMIT_EXCEEDEDwith the reasonplan_limit.
The response is the programme at its first revision, shortened here:
{
"id": "p7Kd2LmQ9xTe",
"rev": 1,
"name": "Leg Day A",
"customerCanEdit": false,
"customerCanCopy": true,
"createdBy": null,
"assignees": 0
}createdBy is null because a key created it. In the portal it names the member who did.
2. Find your customers
Customers join by accepting an invitation (what they agree to). With customers:write, POST /v1/orgs/{orgId}/invitations creates one and returns its link once. Wrist Workout sends no email, so share the link yourself. Each link works once and expires after 7 days.
GET /v1/orgs/{orgId}/customers lists the customers who joined. A customer’s id is a link ID: unique to your organisation, and new if the customer leaves and joins again. Use it wherever the API asks for a customerId.
To match a new customer with your own records, put your own reference in the invitation’s label, such as your system’s ID for the person, in up to 48 characters. When they accept, the invitation’s label becomes the customer’s label. On customer.linked, read the customer with GET /v1/orgs/{orgId}/customers/{customerId} and store their id with your record. The customer never sees the label in the apps or on the invitation page, but it is in their data download, so use an ID rather than a note about them. Members can change the label later in the portal, so match on the stored id from then on.
3. Assign the programme
POST /v1/orgs/{orgId}/assignments, with assignments:write, assigns one library programme to 1 to 100 customers. weekdays is optional: the ISO weekdays (1 is Monday, 7 is Sunday) to set to this programme on each customer’s weekly schedule. A slot replaces whatever the customer had on that weekday, and the customer can change it afterwards: it is their calendar.
IDEMPOTENCY_KEY=$(uuidgen) # send the same key again if you retry
curl -X POST https://api.wristworkout.com/v1/orgs/org_id/assignments \
-H "Authorization: Bearer $WW_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $IDEMPOTENCY_KEY" \
-d '{
"programmeId": "p7Kd2LmQ9xTe",
"customerIds": ["c4Rt8NwZ1bYs", "c9Hm3QaV6eKd"],
"weekdays": [2, 4]
}'// Make one key per assignment and store it with your record of it,
// so a retry sends the same key.
const idempotencyKey = crypto.randomUUID();
const url = 'https://api.wristworkout.com/v1/orgs/org_id/assignments';
const res = await fetch(url, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.WW_API_KEY}`,
'Content-Type': 'application/json',
'Idempotency-Key': idempotencyKey,
},
body: JSON.stringify({
programmeId: 'p7Kd2LmQ9xTe',
customerIds: ['c4Rt8NwZ1bYs', 'c9Hm3QaV6eKd'],
weekdays: [2, 4], // Tuesday and Thursday
}),
});
const { results } = await res.json();Each customer gets an outcome, and the request succeeds as a whole even when some could not be assigned:
{
"programmeId": "p7Kd2LmQ9xTe",
"results": [
{ "customerId": "c4Rt8NwZ1bYs", "outcome": "assigned" },
{ "customerId": "c9Hm3QaV6eKd", "outcome": "already_assigned" }
]
}| Outcome | What it means |
|---|---|
assigned | Done. A programme.assigned event follows. |
already_assigned | The customer already had it, so no event is sent. Any weekdays you sent are still set on their schedule. |
not_linked | Not one of your customers, or, for a trainer, not a customer they coach. The API does not say which. |
limit_exceeded | The customer already has 30 active programmes, their own and assigned ones together. |
A customer can have at most 30 active programmes, their own and assigned ones together, because that is how many plans the watch holds.
What the customer sees
An assigned programme appears on the customer’s Today, in their programme list, on their schedule for the weekdays you set, and on their watch at its next sync. It shows as yours, for example “From Iron Gym”, with what the flags allow. The customer can remove it from their own list at any time. Their watch needs no change.
4. Publish changes
To change a programme, send all of it with PUT /v1/orgs/{orgId}/programmes/{programmeId} and the revision you edited in If-Match. Read the revision from rev, or from the ETag header of GET /v1/orgs/{orgId}/programmes/{programmeId}. The example reads and then saves, so its key needs programmes:read and programmes:write.
const url =
'https://api.wristworkout.com/v1/orgs/org_id/programmes/p7Kd2LmQ9xTe';
const auth = { Authorization: `Bearer ${process.env.WW_API_KEY}` };
// A response describes each station in full;
// a save takes only the editor fields.
const toEditorBody = (p) => ({
name: p.name,
watchName: p.watchName,
unit: p.unit,
notes: p.notes,
stations: p.stations.map((s) => ({
stationId: s.stationId,
exerciseId: s.exerciseId,
machineId: s.machineId,
sets: s.sets,
restS: s.restS,
restHr: s.restHr,
note: s.note,
})),
});
const current = await fetch(url, { headers: auth });
const programme = toEditorBody(await current.json());
programme.stations[1].restS = 75;
const res = await fetch(url, {
method: 'PUT',
headers: {
...auth,
'Content-Type': 'application/json',
'If-Match': current.headers.get('ETag'),
},
body: JSON.stringify(programme),
});
if (res.status === 412) {
// Someone saved first: fetch the new revision,
// apply the change again and retry.
}- Each save publishes a new revision. Earlier revisions never change, so recorded workouts keep the plan they followed.
- Every customer the programme is assigned to gets the new revision at their watch’s next sync. A workout in progress finishes on the revision it started with.
- If someone saved first, you get 412
REVISION_CONFLICTwith the current revision indetails.rev. - Keep each station’s
stationIdto change that station; leave it out to add a new one.
5. Unassign
DELETE /v1/orgs/{orgId}/assignments/{programmeId}/{customerId} ends one assignment. The programme leaves the customer’s programme list, weekly schedule and future days, and their watch drops it at its next sync. Workouts already recorded keep it.
To end every assignment of a programme at once, archive it with DELETE /v1/orgs/{orgId}/programmes/{programmeId}. An archived programme can still be read, but a new revision gets 422 PLAN_ARCHIVED, and it cannot be assigned.
Keep your system in step
Webhooks report each step: programme.assigned for each customer you assign, programme.updated for each new revision, and programme.unassigned when an assignment ends, including when the customer removes it or deletes their account (ending a link). See Webhooks.
One programme for one customer
An assigned programme is one programme shared by everyone it is assigned to, so your edits reach all of them. For a version made for one customer, duplicate it with POST /v1/orgs/{orgId}/programmes/{programmeId}/duplicate and assign the copy to that customer alone.