Skip to content

Goals & Achievements

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

VitaSync includes a full goal-setting and achievement system. Users can set measurable health goals (steps, sleep, heart rate, etc.) and the platform automatically evaluates progress based on synced wearable data. Achievements are awarded when milestones are reached.

Terminal window
curl -X POST http://localhost:3001/v1/users/$USER_ID/goals \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"title": "10K Steps Daily",
"description": "Walk at least 10,000 steps every day",
"category": "activity",
"metricType": "steps",
"targetValue": 10000,
"targetUnit": "steps",
"cadence": "daily",
"startDate": "2025-01-01T00:00:00Z"
}'
FieldTypeRequiredDescription
titlestringYesGoal name (max 200 chars)
descriptionstringNoDetailed description (max 1000 chars)
categorystringYesCategory: activity, sleep, heart, body, nutrition, custom
metricTypestringYesThe health metric to track (e.g. steps, sleep_duration, resting_heart_rate)
targetValuenumberYesTarget value to reach
targetUnitstringYesUnit of measurement
cadencestringYesdaily, weekly, monthly, or one_time
startDateISO 8601YesWhen to start tracking
endDateISO 8601NoOptional end date
MethodPathDescription
GET/v1/users/:userId/goalsList goals (filter by status, category)
POST/v1/users/:userId/goalsCreate a goal
GET/v1/users/:userId/goals/:goalIdGet goal details
PUT/v1/users/:userId/goals/:goalIdUpdate a goal
DELETE/v1/users/:userId/goals/:goalIdDelete a goal
POST/v1/users/:userId/goals/:goalId/evaluateTrigger manual progress evaluation

Goals track these progress fields automatically:

FieldDescription
currentValueLatest measured value
bestValueBest value achieved
currentStreakCurrent consecutive days/weeks meeting the goal
longestStreakAll-time longest streak
percentCompleteProgress toward target (0–100)

Call the evaluate endpoint to trigger a manual progress check, or progress is updated automatically after each sync.

StatusDescription
activeCurrently being tracked
completedTarget achieved
abandonedUser chose to stop tracking

Achievements are awarded automatically when users hit milestones — personal records, streak targets, cumulative totals, etc.

MethodPathDescription
GET/v1/users/:userId/achievementsList unlocked achievements (filter by category)
GET/v1/achievements/definitionsList all available achievement definitions
POST/v1/users/:userId/achievements/checkTrigger achievement evaluation
{
"achievementId": "steps_100k_week",
"category": "activity",
"name": "Century Walker",
"description": "Walk 100,000 steps in a single week",
"tier": "gold",
"unlockedAt": "2025-03-15T14:30:00.000Z"
}

Achievements can have tiers for progressive difficulty:

TierTypical requirement
bronzeEntry-level milestone
silverModerate achievement
goldSignificant accomplishment
platinumElite-level milestone
1. **Create a daily steps goal** ```bash curl -X POST http://localhost:3001/v1/users/$USER_ID/goals \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{"title":"10K Steps","category":"activity","metricType":"steps","targetValue":10000,"targetUnit":"steps","cadence":"daily","startDate":"2025-01-01T00:00:00Z"}' ```
  1. Check progress after a sync

    Terminal window
    curl -X POST http://localhost:3001/v1/users/$USER_ID/goals/$GOAL_ID/evaluate \
    -H "Authorization: Bearer $API_KEY"
  2. View unlocked achievements

    Terminal window
    curl http://localhost:3001/v1/users/$USER_ID/achievements \
    -H "Authorization: Bearer $API_KEY"