Skip to main content

API Reference

All API routes require Clerk authentication via getCurrentUser() from MO:SELF.


Endpoints by Domain​

MO:PULSE (Tracking)​

EndpointMethodDescription
/api/ppl/todayGETToday's workout from PPL rotation
/api/ppl/sessionPOSTStart a workout session
/api/ppl/sessionPATCHComplete a workout session
/api/ppl/session/setsPOSTLog a set
/api/weightGET/POSTWeight tracking
/api/recoveryGET/POSTRecovery logging
/api/warmupGET/POSTWarmup tracking

MO:SELF (Foundation)​

EndpointMethodDescription
/api/streaksGETWorkout streak data
/api/recordsGETPersonal records
/api/preferencesGET/PATCHUser preferences

MO:COACH (Intelligence)​

EndpointMethodDescription
/api/progressionGETProgression analysis
/api/training/statusGET/POSTFatigue & deload status
/api/training/suggestGETWeight suggestions

MO:CONNECT (Library)​

EndpointMethodDescription
/api/exercises/alternativesGETExercise alternatives by pattern
/api/programsGETAvailable programs

Common Patterns​

Authentication​

All endpoints use Clerk for authentication:

import { getCurrentUser } from '@/lib/mo-self';

export async function GET() {
const user = await getCurrentUser();
if (!user) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
}
// ... rest of handler
}

Error Responses​

StatusDescription
401Unauthorized - not logged in
400Bad Request - invalid parameters
404Not Found - resource doesn't exist
500Server Error - unexpected error
{
"error": "Error message here"
}

Success Responses​

All successful responses return JSON with the relevant data.


Quick Examples​

Start a Workout​

POST /api/ppl/session
Content-Type: application/json

{
"templateDayId": "abc123"
}

Log a Set​

POST /api/ppl/session/sets
Content-Type: application/json

{
"sessionExerciseId": "xyz789",
"setNumber": 1,
"weight": 135,
"reps": 8,
"rpe": 7
}

Get Today's Workout​

GET /api/ppl/today

Log Recovery​

POST /api/recovery
Content-Type: application/json

{
"sleepHours": 7.5,
"sleepQuality": 4,
"energyLevel": 4,
"overallSoreness": 2,
"stressLevel": 3
}