Skip to content

Challenges & Training Plans

import { Aside, Steps } from ‘@astrojs/starlight/components’;

VitaSync supports workspace-wide fitness challenges with leaderboards and AI-generated training plans.

Challenges are multi-user competitions within a workspace. Users compete on a specific health metric over a defined time period.

Terminal window
curl -X POST http://localhost:3001/v1/challenges \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"title": "March Step Challenge",
"description": "Who can walk the most steps this month?",
"metricType": "steps",
"goalValue": 300000,
"startDate": "2025-03-01T00:00:00Z",
"endDate": "2025-03-31T23:59:59Z",
"maxParticipants": 50
}'
1. **Draft** — Challenge is created but not yet visible to participants. 2. **Active** — Challenge is open for joining and scores are tracked. 3. **Completed** — End date has passed; final leaderboard is locked. 4. **Cancelled** — Challenge was cancelled before completion.
Terminal window
curl -X POST http://localhost:3001/v1/challenges/$CHALLENGE_ID/activate \
-H "Authorization: Bearer $API_KEY"
Terminal window
curl -X POST http://localhost:3001/v1/challenges/$CHALLENGE_ID/join \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"userId": "'$USER_ID'"}'
Terminal window
curl http://localhost:3001/v1/challenges/$CHALLENGE_ID/leaderboard \
-H "Authorization: Bearer $API_KEY"

Response:

{
"data": [
{ "userId": "...", "rank": 1, "score": 125000, "dailyScores": { "2025-03-15": 12000 } },
{ "userId": "...", "rank": 2, "score": 98000, "dailyScores": { "2025-03-15": 9800 } }
]
}
MethodPathDescription
GET/v1/challengesList workspace challenges (filter by status)
POST/v1/challengesCreate a challenge
GET/v1/challenges/:challengeIdGet challenge details
POST/v1/challenges/:challengeId/activateActivate a draft challenge
POST/v1/challenges/:challengeId/joinJoin a challenge
POST/v1/challenges/:challengeId/leaveLeave a challenge
GET/v1/challenges/:challengeId/leaderboardView leaderboard

AI-generated training plans adapt to user goals, fitness level, and available time.

Terminal window
curl -X POST http://localhost:3001/v1/users/$USER_ID/training-plans/generate \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"goal": "endurance",
"difficulty": "intermediate",
"durationWeeks": 12,
"daysPerWeek": 4,
"focusAreas": ["running", "cycling"]
}'
GoalFocus
enduranceBuild aerobic capacity and distance
strengthResistance training and power
weight_lossCaloric deficit with mixed training
general_fitnessBalanced fitness improvement
flexibilityMobility and stretching routines
LevelDescription
beginnerNew to structured training
intermediateConsistent training for 3+ months
advancedExperienced athlete, high-intensity capable
{
"id": "01HX...",
"userId": "...",
"name": "12-Week Endurance Builder",
"goal": "endurance",
"difficulty": "intermediate",
"durationWeeks": 12,
"currentWeek": 1,
"status": "active",
"schedule": { "...weekly schedule..." },
"weeklyTargets": { "...progressive targets..." },
"adherenceRate": 0,
"adaptive": true
}
MethodPathDescription
GET/v1/users/:userId/training-plansList plans (filter by status)
GET/v1/users/:userId/training-plans/:planIdGet plan details
POST/v1/users/:userId/training-plans/generateGenerate a new plan
POST/v1/users/:userId/training-plans/:planId/progressUpdate training progress