Docs Guides
Building the learner experience
The endpoints behind a course player, and the rules they enforce.
Everything a learner does happens inside an enrollment, under /api/v1/me/enrollments/{id}/…. The enrollment must be the caller’s own (otherwise 404, as if it didn’t exist), and active to act. A completed one can still be viewed.
A course player in five calls#
| Step | Call |
|---|---|
| List my courses | GET /me/enrollments |
| Show the outline | GET /me/enrollments/{e}/course |
| Open a lesson | GET /me/enrollments/{e}/lessons/{l} |
| Track time | PUT /me/enrollments/{e}/lessons/{l}/progress |
| Mark done | POST /me/enrollments/{e}/lessons/{l}/complete |
Rules worth knowing#
- Opening starts. Opening a lesson starts it, and a
VIEWEDlesson completes right there. - Sequential unlock. With
unlockMode: AFTER_PREVIOUS, a lesson islockeduntil the nearest earlier required lesson is complete. The outline tells you which are locked. - Progress is completed required lessons divided by required lessons.
- Completion follows the course’s policy. It completes the enrollment, emits
enrollment.completed, issues the certificate, and frees the seat. A completed learner is never re-enrolled automatically. - Resume. Send
resumeState(for example a video position) in the heartbeat. It comes back when the lesson is opened.
Heartbeat#
ENROLLMENT_ID=8b76f3d8-59e7-4058-910d-15418a61b368
LESSON_ID=3d477cf4-98e8-48b4-997a-a370054d706c
curl -X PUT "$LMS_URL/api/v1/me/enrollments/$ENROLLMENT_ID/lessons/$LESSON_ID/progress" \
-H "Authorization: Bearer $LMS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"secondsSpent": 30,
"resumeState": {
"position": 142
}
}'const LMS_URL = process.env.LMS_URL
const LMS_TOKEN = process.env.LMS_TOKEN
const enrollmentId = "8b76f3d8-59e7-4058-910d-15418a61b368"
const lessonId = "3d477cf4-98e8-48b4-997a-a370054d706c"
const res = await fetch(`${LMS_URL}/api/v1/me/enrollments/${enrollmentId}/lessons/${lessonId}/progress`, {
method: 'PUT',
headers: { "Authorization": `Bearer ${LMS_TOKEN}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
"secondsSpent": 30,
"resumeState": {
"position": 142
}
}),
})
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`)
const data = await res.json()const LMS_URL = process.env.LMS_URL!
const LMS_TOKEN = process.env.LMS_TOKEN!
const enrollmentId = "8b76f3d8-59e7-4058-910d-15418a61b368"
const lessonId = "3d477cf4-98e8-48b4-997a-a370054d706c"
const res = await fetch(`${LMS_URL}/api/v1/me/enrollments/${enrollmentId}/lessons/${lessonId}/progress`, {
method: 'PUT',
headers: { "Authorization": `Bearer ${LMS_TOKEN}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
"secondsSpent": 30,
"resumeState": {
"position": 142
}
}),
})
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`)
const data: unknown = await res.json()import os
import requests
LMS_URL = os.environ["LMS_URL"]
HEADERS = {"Authorization": "Bearer " + os.environ["LMS_TOKEN"]}
enrollment_id = "8b76f3d8-59e7-4058-910d-15418a61b368"
lesson_id = "3d477cf4-98e8-48b4-997a-a370054d706c"
res = requests.put(f"{LMS_URL}/api/v1/me/enrollments/{enrollment_id}/lessons/{lesson_id}/progress", headers=HEADERS, json={
"secondsSpent": 30,
"resumeState": {
"position": 142,
},
}, timeout=10)
res.raise_for_status()
data = res.json()import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Request {
public static void main(String[] args) throws Exception {
String lmsUrl = System.getenv("LMS_URL");
String lmsToken = System.getenv("LMS_TOKEN");
String enrollmentId = "8b76f3d8-59e7-4058-910d-15418a61b368";
String lessonId = "3d477cf4-98e8-48b4-997a-a370054d706c";
String body = """
{
"secondsSpent": 30,
"resumeState": {
"position": 142
}
}
""";
var request = HttpRequest.newBuilder(URI.create(lmsUrl + "/api/v1/me/enrollments/" + enrollmentId + "/lessons/" + lessonId + "/progress"))
.header("Authorization", "Bearer " + lmsToken)
.header("Content-Type", "application/json")
.method("PUT", HttpRequest.BodyPublishers.ofString(body))
.build();
var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() >= 300) throw new IllegalStateException(response.statusCode() + " " + response.body());
System.out.println(response.body());
}
}require "net/http"
require "json"
lms_url = ENV.fetch("LMS_URL")
enrollment_id = "8b76f3d8-59e7-4058-910d-15418a61b368"
lesson_id = "3d477cf4-98e8-48b4-997a-a370054d706c"
uri = URI("#{lms_url}/api/v1/me/enrollments/#{enrollment_id}/lessons/#{lesson_id}/progress")
request = Net::HTTP::Put.new(uri, "Authorization" => "Bearer " + ENV.fetch("LMS_TOKEN"), "Content-Type" => "application/json")
request.body = {
"secondsSpent" => 30,
"resumeState" => {
"position" => 142,
},
}.to_json
response = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(request) }
raise "#{response.code} #{response.body}" unless response.is_a?(Net::HTTPSuccess)
data = JSON.parse(response.body)<?php
$lmsUrl = getenv('LMS_URL');
$enrollmentId = "8b76f3d8-59e7-4058-910d-15418a61b368";
$lessonId = "3d477cf4-98e8-48b4-997a-a370054d706c";
$ch = curl_init("$lmsUrl/api/v1/me/enrollments/{$enrollmentId}/lessons/{$lessonId}/progress");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('LMS_TOKEN'), 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
"secondsSpent" => 30,
"resumeState" => [
"position" => 142,
],
]),
]);
$response = curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_RESPONSE_CODE) >= 300) {
throw new RuntimeException($response);
}
$data = json_decode($response, true);package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
enrollmentId := "8b76f3d8-59e7-4058-910d-15418a61b368"
lessonId := "3d477cf4-98e8-48b4-997a-a370054d706c"
body := strings.NewReader(`{
"secondsSpent": 30,
"resumeState": {
"position": 142
}
}`)
req, _ := http.NewRequest("PUT", os.Getenv("LMS_URL") + "/api/v1/me/enrollments/" + enrollmentId + "/lessons/" + lessonId + "/progress", body)
req.Header.Set("Authorization", "Bearer " + os.Getenv("LMS_TOKEN"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
if res.StatusCode >= 300 {
panic(fmt.Sprintf("%d %s", res.StatusCode, data))
}
fmt.Println(string(data))
}secondsSpent is 0 to 300 per call.
Files#
Fetch course files from GET /me/enrollments/{e}/assets/{assetId}/content. Only files used by the learner’s course version are served.
Expiry#
Enrollments past expiresAt become EXPIRED (seat released). Access is also blocked immediately on read, so correctness never depends on a background job’s timing.
Tip
These endpoints take a learner token, not an API key. If your app has its own users, have your server call POST /learners/{your-user-id}/session to get a token for each (see the Quickstart). People who joined by invitation sign in with their own password instead.