POST /scorm/sessions/:sessionId/sync

POST /scorm/sessions/:sessionId/sync

SCORM API URL localhost:3001'; Request validation schema POST /api/scorm/sessions/[sessionId]/sync Validate UUID format Check if this is an internal request (from webhook handler) Normal request - require Clerk authentication Get user profile For internal requests, we need to fetch session first to get user_id, then get profile For normal requests, we already have profile Parse and validate request body For internal requests, fetch session first to get user_id, then get profile Fetch session data from SCORM API to get user_id Get profile from session.user_id (we'll fetch full session again later) At this point, profile must be set Verify activity exists and belongs to user's tenant Fetch session data from SCORM API Verify session belongs to user (profile is already set at this point) Verify session belongs to tenant Extract CMI data first Determine SCORM version from package or CMI data Check version string or infer from CMI data structure Default to 1.2 SCORM 2004 uses cmi.completion_status, 1.2 uses cmi.core.lesson_status Map SCORM status to LMS status SCORM 2004 Extract score Get or create activity_progress record first Extract time spent (use session.time_spent_seconds if available, otherwise parse from CMI) Prefer session.time_spent_seconds as it's already calculated and accumulated by SCORM API Fallback to parsing from CMI data if session time not available If we have existing progress, use the maximum time (SCORM API accumulates, so new should be >= existing) Use the maximum of existing time or new time (SCORM API accumulates, so new should be >= existing) Set timestamps based on status Update attempt count only when status changes to a terminal state (completed or failed) Don't increment on every sync - only when status actually changes to a terminal state Increment if transitioning to a terminal state from a non-terminal state Preserve existing attempt count New progress record - first attempt Update existing progress Create new progress record If activity was completed, recalculate enrollment progress

Endpoint

POST /scorm/sessions/:sessionId/sync

Authentication

This endpoint requires authentication. Include your authentication token in the request headers.

Path Parameters

ParameterTypeDescription
sessionIdstringPath parameter

Error Responses

Status CodeError CodeDescription
400HTTP_400Bad Request
401HTTP_401Unauthorized
404HTTP_404Not Found
400HTTP_400Bad Request
404HTTP_404Not Found
404HTTP_404Not Found
404HTTP_404Not Found
404HTTP_404Not Found
404HTTP_404Not Found
404HTTP_404Not Found
403HTTP_403Forbidden
403HTTP_403Forbidden
500HTTP_500Internal Server Error
500HTTP_500Internal Server Error
500HTTP_500Internal Server Error

Example Request

curl -X POST "https://api.allurelms.com/scorm/sessions/sessionId-value/sync" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}'