Loki Docs
Tools › Workouts › Log a set

Log a set

log_setAdds
What it does
Adds a new record and leaves what you had alone. Safe to retry: the same call twice changes nothing more.
Permission
Workouts, change workouts:write

What your assistant is told

Log one completed set into a workout — by default the user's IN-PROGRESS one. The exercise is referenced by exercise (from find_exercises) and is added to the session automatically if not already present. Pass sessionId (from list_workouts) to add a set the user performed but forgot to log on a FINISHED workout — the set is stamped with that workout's end time and the workout's start, end and duration do not move. Without sessionId it fails when no workout is in progress — call start_workout first. To record a whole past workout at once use create_workout instead. THE SET FOLLOWS THE EXERCISE. get_exercise tells you how, and a set that disagrees is refused rather than stored wrong. - trackingMode says WHICH NUMBER the set carries, and only that one: "reps" → reps; "seconds" → durationSeconds (a plank is a 60-SECOND hold, never 60 reps); "distance" → distanceM, in metres. - loadMode says HOW THE ONE WEIGHT READS: "weight" — the weight entered is the load. "bodyweight_plus" — the load is the user's bodyweight PLUS what you pass, so pass only what was ADDED (a push-up in a 10 kg vest is weightKg: 10), and omit it for a plain set. "bodyweight_signed" — the same, and it also takes ASSISTANCE as a NEGATIVE: one exercise from an assist machine to a weight belt, so a pull-up with a 20 kg belt is weightKg: 20, the same pull-up on a machine set to 20 kg is weightKg: -20, and a strict one omits it. "band" — the weight is an ESTIMATE of the band's tension, not a load: pass the kilograms the band is worth if the user names them and omit it otherwise. "bodyweight" and "none" take no weight at all and refuse one. ("assisted" is retired: a few old rows still read it as bodyweight MINUS a positive counterweight.) - unilateral: true means one limb at a time, so each side is its own set with its own side. Anything else refuses a side. Volume, e1RM and the user's records are all computed from the load read this way, against their bodyweight at the time; with no weigh-in on record a bodyweight-based set counts as a set and adds no kilograms. A "band" set counts as a set and ranks that exercise's own records, and its estimate is never summed into volume, tonnage or a muscle total (D21).

Parameters

  • exercisetext, requiredThe exercise: a catalog slug (e.g. "barbell-back-squat") or the numeric id find_exercises gives you — which is the only way to name one of the user's own exercises, since those have no slug.
  • weightKgnumber, optionalThe set's one weight, in kilograms, read through the exercise's loadMode: the load itself for "weight", what was ADDED for "bodyweight_plus" and "bodyweight_signed". On "bodyweight_signed" pass a NEGATIVE weightKg for assistance — -20 is an assist machine set to 20 kg, 20 is a 20 kg belt, and a strict rep omits it. On "band" it is an ESTIMATE of the band's tension (≈ kg), optional, and never added to volume. A negative is REFUSED on every loadMode but "bodyweight_signed", and "bodyweight" / "none" refuse a weight at all.
  • repswhole number, optionalRepetitions performed. The measure of a reps exercise — required for one, refused on a seconds or distance one.
  • typetext, optionalSet type: Normal | Warmup | Drop | Failure (case-insensitive). Default Normal.
  • rpenumber, optionalOptional Rate of Perceived Exertion, 0-10.
  • durationSecondswhole number, optionalHow long the hold lasted, in seconds. The measure of a seconds exercise (a plank, a dead hang) — required for one, refused on the others.
  • distanceMnumber, optionalHow far it went, in METRES. The measure of a distance exercise (a farmer's walk, a sled push) — required for one, refused on the others. Convert km or miles yourself.
  • sidetext, optional"left" or "right", for an exercise with unilateral: true — one side at a time, so each side is its own set. Refused on anything else. Omitting it on a unilateral exercise is allowed and means the set doesn't say which side.
  • sessionIdid, optionalWorkout UUID from list_workouts. Omit for the in-progress workout.
  • idempotencyKeyid, optionalOptional UUID you generate for THIS write, so retrying it is safe. Pass the SAME key when you retry a call that timed out or errored with an unclear outcome: the server returns the record the first attempt created instead of writing a second one. Generate a fresh key per distinct write — reusing one is how you'd silently skip a second, genuinely new entry. Omit it and every call writes a new record.
  • clientHandletext, optionalOptional client_handle from list_clients to run this tool against a coached client's data instead of your own. Omit (or pass null) for your own data — the legacy default.