Skip to main content
Docs · Getting started

Launch Your First SCORM Session

Updated

Learn how to create learning sessions, launch SCORM players, and track learner progress.

⚠️ Every session launch URL must carry a signed token. The player route at /player/:sessionId will return HTTP 401 without it. The launch endpoint returns a complete launch_url with the token already embedded — use it as-is. Never build .../player/<id> yourself. If you are handing the package to an external LMS, use the dispatch flow instead, which produces a durable record-backed handoff URL.

Table of Contents

Overview

A SCORM session represents a learner's interaction with a SCORM package. Sessions track:

  • CMI Data: Progress, scores, completion status
  • Time Spent: Total learning time
  • Attempts: Number of times the course was accessed
  • State: Current learning state (incomplete, completed, passed, failed)

Prerequisites

  • API key with public_api, internal_product, or admin scope
  • A successfully uploaded SCORM package
  • A user ID (your system's learner identifier)

Creating a Session

The launch endpoint creates a session and returns a fully signed launch URL in one call. Mint the URL when the learner clicks Play, not earlier. The default token TTL is 14,400 seconds (4 hours), and the response reports the effective TTL after platform min/max clamping.

bash
curl -X POST https://app.allureconnect.com/api/v1/packages/pkg_abc123/launch \
  -H "Authorization: Bearer your-api-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "user_id": "user-123",
    "session_id": "550e8400-e29b-41d4-a716-446655440001"
  }'

Response:

json
{
  "package_id": "pkg_abc123",
  "session_id": "550e8400-e29b-41d4-a716-446655440001",
  "learner_id": "user-123",
  "content_type": "scorm",
  "storage_backend": "r2",
  "launch_url": "https://app.allureconnect.com/player/550e8400-e29b-41d4-a716-446655440001?token=eyJhbGciOi...",
  "expires_in_seconds": 14400
}

Use launch_url as-is. The ?token= query param is the learner's signed session token. Treat the whole string as one opaque URL — don't strip, shorten, or rebuild it.

If you are embedding a SCORM package into a third-party LMS (Moodle, Docebo, etc.), don't use Method 1. Instead, create a dispatch — one per LMS destination — and hand the returned dispatch_url / dispatch.launchUrl to the LMS. Connect mints short-lived learner sessions when the dispatch URL is launched, and the dispatch record can be rotated or revoked centrally.

See the full guide in Custom LMS Integration. For Allure Training OS specifically, see Allure Training OS Integration. Short version:

bash
curl -X POST https://app.allureconnect.com/api/v1/packages/pkg_abc123/dispatches \
  -H "Authorization: Bearer your-api-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "label": "Acme LMS – Onboarding",
    "destination": "acme-moodle"
  }'

Response:

json
{
  "dispatch": {
    "id": "dsp_…",
    "launchUrl": "https://app.allureconnect.com/player/dispatch/dsp_…"
  },
  "dispatch_url": "https://app.allureconnect.com/player/dispatch/dsp_…"
}

Launching the Player

Use the launch_url returned by POST /api/v1/packages/:id/launch (Method 1) or the launchUrl returned by the dispatch endpoint (Method 2). Do not hand-construct …/player/<sessionId> — that will 401.

html
<!-- `launchUrl` is the exact string returned by the launch or dispatch endpoint -->
<iframe
  src="<launchUrl>"
  width="100%"
  height="800px"
  frameborder="0"
  allow="fullscreen"
  title="SCORM Player"
></iframe>

Option 2: Redirect to Player

javascript
// launchUrl comes from the launch endpoint response — use as-is.
window.location.href = launchUrl;

Option 3: Open in New Window

javascript
window.open(launchUrl, 'SCORM Player', 'width=1200,height=800');

Tracking Progress

Get Session Data

Retrieve current session state and CMI data:

bash
curl -X GET https://app.allureconnect.com/api/v1/sessions/770e8400-e29b-41d4-a716-446655440000 \
  -H "X-API-Key: your-api-key-here"

Response:

json
{
  "id": "770e8400-e29b-41d4-a716-446655440000",
  "tenant_id": "550e8400-e29b-41d4-a716-446655440000",
  "user_id": "user-123",
  "package_id": "pkg_abc123",
  "cmi_data": {
    "cmi.progress_measure": "0.4",
    "cmi.completion_status": "incomplete",
    "cmi.score.scaled": "0.75",
    "cmi.session_time": "PT15M30S"
  },
  "completion_status": "incomplete",
  "success_status": "unknown",
  "progress_percent": 40,
  "progress": 40,
  "score": {
    "scaled": 0.75,
    "raw": 75,
    "max": 100,
    "min": 0
  },
  "time_spent_seconds": 930,
  "version": 3,
  "created_at": "2025-01-15T10:00:00.000Z",
  "updated_at": "2025-01-15T10:15:30.000Z"
}

Polling for Updates

Check session progress periodically. Read root progress_percent (alias progress) and package_id. Nested session is camelCase for the hosted player (progressPercent, packageId).

Connect only updates those numbers when the hosted player (or your LMS) PUTs CMI. Polling GET does not invent progress. There is no session.progress webhook — subscribe to session.completed / session.failed / session.suspended for terminal events.

SCORM 2004 cmi.progress_measure (0..1, or 0..100) maps onto progress_percent. Incomplete sessions cap at 99. SCORM 1.2 courses that never send progress_measure stay at 0 until completion_status is completed, passed, or failed.

typescript
async function pollSessionProgress(sessionId: string) {
  const interval = setInterval(async () => {
    const response = await fetch(`/api/v1/sessions/${sessionId}`, {
      headers: { 'X-API-Key': apiKey }
    });
    const session = await response.json();

    console.log(`Progress: ${session.progress_percent}% (${session.completion_status})`);
    console.log(`Score: ${session.score?.scaled || 0}`);

    if (session.completion_status === 'completed' || session.completion_status === 'passed' || session.completion_status === 'failed') {
      clearInterval(interval);
      console.log('Course completed!');
    }
  }, 5000); // Poll every 5 seconds
}

Updating Session Data

Update CMI Data

The SCORM player automatically updates session data, but you can also update it programmatically:

bash
curl -X PUT https://app.allureconnect.com/api/v1/sessions/770e8400-e29b-41d4-a716-446655440000 \
  -H "X-API-Key: your-api-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "version": 3,
    "cmi_data": {
      "cmi.core.lesson_status": "completed",
      "cmi.core.score.raw": "85",
      "cmi.core.score.max": "100",
      "cmi.core.session_time": "PT20M45S"
    },
    "completion_status": "completed",
    "success_status": "passed",
    "score": {
      "scaled": 0.85,
      "raw": 85,
      "max": 100,
      "min": 0
    },
    "session_time": "PT20M45S"
  }'

Important: Always include the version field for optimistic locking. If you get a 409 Conflict error, fetch the latest session data and retry.

Handling Version Conflicts

typescript
async function updateSessionWithRetry(
  sessionId: string,
  updates: any,
  maxRetries = 3
) {
  for (let attempt = 0; attempt < maxRetries; attempt++) {
    // 1. Get current session
    const session = await fetch(`/api/v1/sessions/${sessionId}`, {
      headers: { 'X-API-Key': apiKey }
    }).then(r => r.json());

    // 2. Merge updates
    const payload = {
      version: session.version,
      cmi_data: {
        ...session.cmi_data,
        ...updates.cmi_data
      },
      ...updates
    };

    // 3. Attempt update
    const response = await fetch(`/api/v1/sessions/${sessionId}`, {
      method: 'PUT',
      headers: {
        'X-API-Key': apiKey,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify(payload)
    });

    if (response.ok) {
      return await response.json();
    }

    if (response.status === 409 && attempt < maxRetries - 1) {
      console.log(`Version conflict, retrying... (${attempt + 1}/${maxRetries})`);
      continue;
    }

    throw new Error(`Update failed: ${response.status}`);
  }
}

Common Scenarios

Scenario 1: Launch and Track Completion

typescript
// 1. Launch session
const launchResponse = await fetch(`/api/v1/packages/${packageId}/launch`, {
  method: 'POST',
  headers: {
    'X-API-Key': apiKey,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    user_id: userId,
    session_id: sessionId
  })
});
const { launch_url, session_id } = await launchResponse.json();

// 2. Embed player — launch_url already includes the signed ?token=
const iframe = document.createElement('iframe');
iframe.src = launch_url;
iframe.width = '100%';
iframe.height = '800px';
document.body.appendChild(iframe);

// 3. Poll for completion
const checkCompletion = setInterval(async () => {
  const session = await fetch(`/api/v1/sessions/${session_id}`, {
    headers: { 'X-API-Key': apiKey }
  }).then(r => r.json());

  if (session.completion_status === 'completed') {
    clearInterval(checkCompletion);
    showCompletionMessage(session);
  }
}, 5000);

Scenario 2: Resume Previous Session

Resume by relaunching the same session id. That returns a fresh tokenized launch_url. Embed that URL — do not load package launcher.html or /player/{id} without ?token=.

POST /api/v1/sessions/{id}/refresh-token rotates a JWT for the same session. Callers may embed the returned launch_url to reopen the hosted player. It does not persist CMI by itself.

typescript
// 1. Find existing session
const sessionsResponse = await fetch(
  `/api/v1/sessions?package_id=${packageId}&user_id=${userId}`,
  { headers: { 'X-API-Key': apiKey } }
);
const { sessions } = await sessionsResponse.json();

// 2. Find incomplete session
const incompleteSession = sessions.find(
  s => s.completion_status === 'incomplete'
);

// Resuming or creating, always hit /launch — it re-mints a fresh signed
// launch_url whether the session already existed or was just created.
const launchResponse = await fetch(`/api/v1/packages/${packageId}/launch`, {
  method: 'POST',
  headers: {
    'X-API-Key': apiKey,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    user_id: userId,
    session_id: incompleteSession?.id ?? crypto.randomUUID()
  })
});
const { launch_url } = await launchResponse.json();
window.location.href = launch_url;

Scenario 3: Track Multiple Users

typescript
async function launchForMultipleUsers(packageId: string, userIds: string[]) {
  const sessions = [];

  for (const userId of userIds) {
    const response = await fetch(`/api/v1/packages/${packageId}/launch`, {
      method: 'POST',
      headers: {
        'X-API-Key': apiKey,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        user_id: userId,
        session_id: crypto.randomUUID()
      })
    });

    if (response.ok) {
      const session = await response.json();
      sessions.push(session);
    }
  }

  return sessions;
}

Troubleshooting

Error: "Session Not Found"

Causes:

  • Invalid session ID
  • Session expired
  • Session belongs to different tenant

Solutions:

  • Verify session ID is correct
  • Check session expiration time
  • Ensure API key matches tenant

Error: "Version Conflict" (409)

Causes:

  • Concurrent updates to same session
  • Using outdated version number

Solutions:

Error: "Package Not Found"

Causes:

  • Invalid package ID
  • Package deleted
  • Package belongs to different tenant

Solutions:

  • Verify package ID
  • Check package exists
  • Ensure API key matches tenant

Most common cause: the URL was constructed as .../player/<sessionId> without the ?token= query parameter. Learners hitting the player without a signed session token are unauthenticated and always 401.

Fix:

  • Always use the launch_url field from POST /api/v1/packages/:id/launch as-is — it already contains the signed token.
  • For LMS hand-off, use dispatch launchUrl from POST /api/v1/packages/:id/dispatches.
  • Do not cache or store tokenless URLs. Re-mint when the learner clicks Play.
  • Token TTL defaults to 14,400s. An already-open player should refresh via POST /api/v1/sessions/{sessionId}/refresh-token before expiry (the response now includes launch_url). To reopen a course in an LMS, POST /api/v1/packages/:id/launch with the existing session_id and embed that launch_url.

Player Not Loading (other causes)

Causes:

  • CORS issues
  • Network connectivity
  • Package launch_url missing from manifest

Solutions:

  • Check browser console for errors
  • Verify CORS configuration
  • Ensure the package upload completed successfully

Best Practices

  1. Use Unique Session IDs: Generate UUIDs for session IDs to avoid conflicts
  2. Handle Version Conflicts: Always implement retry logic for session updates
  3. Poll for Progress: Check session status periodically for real-time updates
  4. Resume Sessions: Check for existing incomplete sessions, then POST /api/v1/packages/{id}/launch with that session_id and embed the returned launch_url. Do not treat refresh-token as an LMS reopen unless you iframe its launch_url.
  5. Monitor Expiration: Track expires_in_seconds and refresh the session token before expiry
  6. Error Handling: Implement comprehensive error handling for all API calls

Next Steps


Related Documentation: