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
| Parameter | Type | Description |
|---|---|---|
sessionId | string | Path parameter |
Error Responses
| Status Code | Error Code | Description |
|---|---|---|
| 400 | HTTP_400 | Bad Request |
| 401 | HTTP_401 | Unauthorized |
| 404 | HTTP_404 | Not Found |
| 400 | HTTP_400 | Bad Request |
| 404 | HTTP_404 | Not Found |
| 404 | HTTP_404 | Not Found |
| 404 | HTTP_404 | Not Found |
| 404 | HTTP_404 | Not Found |
| 404 | HTTP_404 | Not Found |
| 404 | HTTP_404 | Not Found |
| 403 | HTTP_403 | Forbidden |
| 403 | HTTP_403 | Forbidden |
| 500 | HTTP_500 | Internal Server Error |
| 500 | HTTP_500 | Internal Server Error |
| 500 | HTTP_500 | Internal 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 '{}'