{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"/api/v1/plan-schema","title":"Workout Relay running plan","type":"object","additionalProperties":false,"required":["schema_version","plan_id","title","workouts"],"properties":{"schema_version":{"const":1},"plan_id":{"type":"string","pattern":"^[a-zA-Z0-9][a-zA-Z0-9_-]{2,99}$"},"title":{"type":"string","minLength":1,"maxLength":120},"description":{"type":"string","maxLength":1000},"workouts":{"type":"array","minItems":1,"maxItems":31,"items":{"$ref":"#/$defs/workout"}}},"$defs":{"workout":{"type":"object","additionalProperties":false,"required":["id","date","sport","title","steps"],"properties":{"id":{"type":"string","pattern":"^[a-z0-9][a-z0-9_-]{1,159}$","description":"Stable workout identity across this account. Keep unchanged when rescheduling."},"date":{"type":"string","format":"date"},"sport":{"enum":["running","strength"],"description":"running uses pace/heart-rate targets; strength uses named Garmin exercises."},"title":{"type":"string","minLength":1,"maxLength":50},"description":{"type":"string","maxLength":500},"estimated_duration_sec":{"type":"integer","minimum":1,"maximum":86400},"steps":{"type":"array","minItems":1,"maxItems":50}},"if":{"properties":{"sport":{"const":"strength"}},"required":["sport"]},"then":{"properties":{"steps":{"items":{"$ref":"#/$defs/strengthStep"}}}},"else":{"properties":{"steps":{"items":{"$ref":"#/$defs/step"}}}}},"step":{"oneOf":[{"$ref":"#/$defs/simpleStep"},{"$ref":"#/$defs/repeatStep"}]},"simpleStep":{"type":"object","additionalProperties":false,"required":["type","duration","target"],"properties":{"type":{"enum":["warmup","interval","recovery","cooldown"]},"name":{"type":"string","maxLength":80},"duration":{"$ref":"#/$defs/duration"},"target":{"$ref":"#/$defs/target"}}},"repeatStep":{"type":"object","additionalProperties":false,"required":["type","count","steps"],"properties":{"type":{"const":"repeat"},"name":{"type":"string","maxLength":80},"count":{"type":"integer","minimum":1,"maximum":50},"steps":{"type":"array","minItems":1,"maxItems":5,"items":{"$ref":"#/$defs/simpleStep"}}}},"duration":{"oneOf":[{"type":"object","additionalProperties":false,"required":["type","value"],"properties":{"type":{"const":"time"},"value":{"type":"integer","minimum":1,"maximum":86400}}},{"type":"object","additionalProperties":false,"required":["type","value"],"properties":{"type":{"const":"distance"},"value":{"type":"integer","minimum":1,"maximum":500000}}}]},"target":{"oneOf":[{"type":"object","additionalProperties":false,"required":["type"],"properties":{"type":{"const":"no_target"}}},{"type":"object","additionalProperties":false,"required":["type","low","high"],"properties":{"type":{"const":"heart_rate"},"low":{"type":"integer","minimum":30,"maximum":250},"high":{"type":"integer","minimum":30,"maximum":250}}},{"type":"object","additionalProperties":false,"required":["type","slow","fast"],"properties":{"type":{"const":"pace"},"slow":{"type":"string","pattern":"^[2-9]:[0-5][0-9]$"},"fast":{"type":"string","pattern":"^[2-9]:[0-5][0-9]$"}}}]},"strengthStep":{"oneOf":[{"$ref":"#/$defs/strengthSimpleStep"},{"$ref":"#/$defs/strengthRepeatStep"}]},"strengthSimpleStep":{"type":"object","additionalProperties":false,"required":["type","duration"],"properties":{"type":{"enum":["warmup","interval","cooldown","rest"]},"exercise":{"type":"string","minLength":1,"maxLength":80,"description":"A Garmin exercise name, e.g. ROMANIAN_DEADLIFT. Search with find_exercises; do not invent one."},"category":{"type":"string","minLength":1,"maxLength":60,"description":"Only needed when the exercise name exists in several categories, or to name a category-only step."},"reason":{"type":"string","minLength":10,"maxLength":300,"description":"Required to send a category-only step: say why no listed exercise fits. Ask the person first."},"name":{"type":"string","maxLength":80},"description":{"type":"string","maxLength":500},"duration":{"$ref":"#/$defs/strengthDuration"},"weight_kg":{"type":"number","minimum":0,"maximum":500}}},"strengthRepeatStep":{"type":"object","additionalProperties":false,"required":["type","count","steps"],"properties":{"type":{"const":"repeat"},"name":{"type":"string","maxLength":80},"count":{"type":"integer","minimum":1,"maximum":50},"steps":{"type":"array","minItems":1,"maxItems":12,"items":{"$ref":"#/$defs/strengthSimpleStep"}}}},"strengthDuration":{"oneOf":[{"type":"object","additionalProperties":false,"required":["type","value"],"properties":{"type":{"const":"reps"},"value":{"type":"integer","minimum":1,"maximum":1000}}},{"type":"object","additionalProperties":false,"required":["type","value"],"properties":{"type":{"const":"time"},"value":{"type":"integer","minimum":1,"maximum":86400}}}]}}}