Docs API reference
Enrollments & progress
Who is taking what, and how far along they are.
An enrollment is the only thing that gives someone access to a course. Use these endpoints to report on progress and to enroll or withdraw people directly.
4 endpoints · base path /api/v1
List enrollments
AccessAdmin, or an API key with the read or write scope.
A page of enrollments with learner, course, status and progress. Filter by courseId, userId, organizationId and status (ACTIVE, COMPLETED, EXPIRED, WITHDRAWN). Newest first; page with limit and offset.
Parameters
| Name | In | Type | Notes |
|---|---|---|---|
| courseId | query | string (uuid) | — |
| userId | query | string (uuid) | — |
| organizationId | query | string (uuid) | — |
| status | query | string | matches ACTIVE|COMPLETED|EXPIRED|WITHDRAWN |
| limit | query | integer (int32) | — |
| offset | query | integer (int32) | — |
Responses
Example response
{
"items": [
{
"completedAt": "2026-11-25T14:03:11Z",
"courseId": "ecec91e5-4eb9-4c55-a6a7-b3c44ebe7561",
"courseSlug": "string",
"courseTitle": "Workplace Safety Essentials",
"dueAt": "2026-11-25T14:03:11Z",
"enrolledAt": "2026-11-25T14:03:11Z",
"expiresAt": "2026-11-25T14:03:11Z",
"id": "37386ae0-0ea5-44e0-a02e-161f807af560",
"lastActivityAt": "2026-11-25T14:03:11Z",
"learnerEmail": "maya.chen@example.com",
"learnerExternalRef": "string",
"learnerName": "Maya Chen",
"organizationId": "44b78147-d73b-4117-ab62-4292d9ca20db",
"progressPercent": 40,
"source": "ROLE",
"status": "ACTIVE",
"userId": "11f967df-4272-482f-ac0b-7bea76dd8093"
}
],
"total": 1
}Errors
| Status | When |
|---|---|
| 401 | Missing, invalid or expired credentials. |
| 403 | Your credential is valid but isn't allowed to do this. |
Errors use RFC 9457 problem details.
curl -X GET "$LMS_URL/api/v1/enrollments?courseId=ecec91e5-4eb9-4c55-a6a7-b3c44ebe7561&userId=11f967df-4272-482f-ac0b-7bea76dd8093" \
-H "X-API-Key: $LMS_KEY"const LMS_URL = process.env.LMS_URL
const LMS_KEY = process.env.LMS_KEY
const res = await fetch(`${LMS_URL}/api/v1/enrollments?courseId=ecec91e5-4eb9-4c55-a6a7-b3c44ebe7561&userId=11f967df-4272-482f-ac0b-7bea76dd8093`, {
method: 'GET',
headers: { "X-API-Key": LMS_KEY },
})
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_KEY = process.env.LMS_KEY!
const res = await fetch(`${LMS_URL}/api/v1/enrollments?courseId=ecec91e5-4eb9-4c55-a6a7-b3c44ebe7561&userId=11f967df-4272-482f-ac0b-7bea76dd8093`, {
method: 'GET',
headers: { "X-API-Key": LMS_KEY },
})
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 = {"X-API-Key": os.environ["LMS_KEY"]}
res = requests.get(f"{LMS_URL}/api/v1/enrollments?courseId=ecec91e5-4eb9-4c55-a6a7-b3c44ebe7561&userId=11f967df-4272-482f-ac0b-7bea76dd8093", headers=HEADERS, 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 lmsKey = System.getenv("LMS_KEY");
var request = HttpRequest.newBuilder(URI.create(lmsUrl + "/api/v1/enrollments?courseId=ecec91e5-4eb9-4c55-a6a7-b3c44ebe7561&userId=11f967df-4272-482f-ac0b-7bea76dd8093"))
.header("X-API-Key", lmsKey)
.method("GET", HttpRequest.BodyPublishers.noBody())
.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")
uri = URI("#{lms_url}/api/v1/enrollments?courseId=ecec91e5-4eb9-4c55-a6a7-b3c44ebe7561&userId=11f967df-4272-482f-ac0b-7bea76dd8093")
request = Net::HTTP::Get.new(uri, "X-API-Key" => ENV.fetch("LMS_KEY"))
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');
$ch = curl_init("$lmsUrl/api/v1/enrollments?courseId=ecec91e5-4eb9-4c55-a6a7-b3c44ebe7561&userId=11f967df-4272-482f-ac0b-7bea76dd8093");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['X-API-Key: ' . getenv('LMS_KEY')],
]);
$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"
)
func main() {
req, _ := http.NewRequest("GET", os.Getenv("LMS_URL") + "/api/v1/enrollments?courseId=ecec91e5-4eb9-4c55-a6a7-b3c44ebe7561&userId=11f967df-4272-482f-ac0b-7bea76dd8093", nil)
req.Header.Set("X-API-Key", os.Getenv("LMS_KEY"))
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))
}Enroll someone directly
AccessAdmin, or an API key with the write scope.
Enrolls a person in a course's published version without any organization or license. Use it for individual learners or one-off access. dueAt and expiresAt are optional.
A person can have only one active enrollment per course, but can retake after completing.
Request body application/json · EnrollRequest
| Field | Type | Notes |
|---|---|---|
| courseIdrequired | string (uuid) | — |
| dueAt | string (date-time) | — |
| expiresAt | string (date-time) | — |
| userIdrequired | string (uuid) | — |
Example request body
{
"userId": "6a2f9c04-e1b7-4d83-85a5-c0d4f7e1b932",
"courseId": "4b2e8f90-1d73-4c5a-9e06-a8f1d3b7c254",
"expiresAt": "2027-06-30T23:59:59Z"
}Responses
Example response
{
"completedAt": "2026-11-25T14:03:11Z",
"courseId": "ecec91e5-4eb9-4c55-a6a7-b3c44ebe7561",
"courseSlug": "string",
"courseTitle": "Workplace Safety Essentials",
"dueAt": "2026-11-25T14:03:11Z",
"enrolledAt": "2026-11-25T14:03:11Z",
"expiresAt": "2026-11-25T14:03:11Z",
"id": "37386ae0-0ea5-44e0-a02e-161f807af560",
"lastActivityAt": "2026-11-25T14:03:11Z",
"learnerEmail": "maya.chen@example.com",
"learnerExternalRef": "string",
"learnerName": "Maya Chen",
"organizationId": "44b78147-d73b-4117-ab62-4292d9ca20db",
"progressPercent": 40,
"source": "ROLE",
"status": "ACTIVE",
"userId": "11f967df-4272-482f-ac0b-7bea76dd8093"
}Errors
| Status | When |
|---|---|
| 400 | Unknown or inactive user, an unknown course or one with no published version, or expiresAt isn't in the future. |
| 401 | Missing, invalid or expired credentials. |
| 403 | Your credential is valid but isn't allowed to do this. |
| 409 | They already have an active enrollment in this course. |
Errors use RFC 9457 problem details.
curl -X POST "$LMS_URL/api/v1/enrollments" \
-H "X-API-Key: $LMS_KEY" \
-H "Content-Type: application/json" \
-d '{
"userId": "6a2f9c04-e1b7-4d83-85a5-c0d4f7e1b932",
"courseId": "4b2e8f90-1d73-4c5a-9e06-a8f1d3b7c254",
"expiresAt": "2027-06-30T23:59:59Z"
}'const LMS_URL = process.env.LMS_URL
const LMS_KEY = process.env.LMS_KEY
const res = await fetch(`${LMS_URL}/api/v1/enrollments`, {
method: 'POST',
headers: { "X-API-Key": LMS_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({
"userId": "6a2f9c04-e1b7-4d83-85a5-c0d4f7e1b932",
"courseId": "4b2e8f90-1d73-4c5a-9e06-a8f1d3b7c254",
"expiresAt": "2027-06-30T23:59:59Z"
}),
})
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_KEY = process.env.LMS_KEY!
const res = await fetch(`${LMS_URL}/api/v1/enrollments`, {
method: 'POST',
headers: { "X-API-Key": LMS_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({
"userId": "6a2f9c04-e1b7-4d83-85a5-c0d4f7e1b932",
"courseId": "4b2e8f90-1d73-4c5a-9e06-a8f1d3b7c254",
"expiresAt": "2027-06-30T23:59:59Z"
}),
})
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 = {"X-API-Key": os.environ["LMS_KEY"]}
res = requests.post(f"{LMS_URL}/api/v1/enrollments", headers=HEADERS, json={
"userId": "6a2f9c04-e1b7-4d83-85a5-c0d4f7e1b932",
"courseId": "4b2e8f90-1d73-4c5a-9e06-a8f1d3b7c254",
"expiresAt": "2027-06-30T23:59:59Z",
}, 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 lmsKey = System.getenv("LMS_KEY");
String body = """
{
"userId": "6a2f9c04-e1b7-4d83-85a5-c0d4f7e1b932",
"courseId": "4b2e8f90-1d73-4c5a-9e06-a8f1d3b7c254",
"expiresAt": "2027-06-30T23:59:59Z"
}
""";
var request = HttpRequest.newBuilder(URI.create(lmsUrl + "/api/v1/enrollments"))
.header("X-API-Key", lmsKey)
.header("Content-Type", "application/json")
.method("POST", 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")
uri = URI("#{lms_url}/api/v1/enrollments")
request = Net::HTTP::Post.new(uri, "X-API-Key" => ENV.fetch("LMS_KEY"), "Content-Type" => "application/json")
request.body = {
"userId" => "6a2f9c04-e1b7-4d83-85a5-c0d4f7e1b932",
"courseId" => "4b2e8f90-1d73-4c5a-9e06-a8f1d3b7c254",
"expiresAt" => "2027-06-30T23:59:59Z",
}.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');
$ch = curl_init("$lmsUrl/api/v1/enrollments");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['X-API-Key: ' . getenv('LMS_KEY'), 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
"userId" => "6a2f9c04-e1b7-4d83-85a5-c0d4f7e1b932",
"courseId" => "4b2e8f90-1d73-4c5a-9e06-a8f1d3b7c254",
"expiresAt" => "2027-06-30T23:59:59Z",
]),
]);
$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() {
body := strings.NewReader(`{
"userId": "6a2f9c04-e1b7-4d83-85a5-c0d4f7e1b932",
"courseId": "4b2e8f90-1d73-4c5a-9e06-a8f1d3b7c254",
"expiresAt": "2027-06-30T23:59:59Z"
}`)
req, _ := http.NewRequest("POST", os.Getenv("LMS_URL") + "/api/v1/enrollments", body)
req.Header.Set("X-API-Key", os.Getenv("LMS_KEY"))
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))
}Get an enrollment's progress
AccessAdmin, or an API key with the read or write scope.
Returns the enrollment, the course version it is pinned to, each lesson's status and time spent, every quiz attempt with its score, and the certificate if one was issued.
Parameters
| Name | In | Type | Notes |
|---|---|---|---|
| idrequired | path | string (uuid) | The id from a previous response. |
Responses
Example response
{
"attempts": [
{
"assessmentTitle": "Safety knowledge check",
"attemptNumber": 1,
"id": "37386ae0-0ea5-44e0-a02e-161f807af560",
"passed": true,
"scorePercent": 86.5,
"status": "ACTIVE",
"submittedAt": "2026-11-25T14:03:11Z"
}
],
"certificateId": "b335ac0d-4339-49fd-ab81-01ace7c46f69",
"courseVersion": 1,
"enrollment": {
"completedAt": "2026-11-25T14:03:11Z",
"courseId": "ecec91e5-4eb9-4c55-a6a7-b3c44ebe7561",
"courseSlug": "string",
"courseTitle": "Workplace Safety Essentials",
"dueAt": "2026-11-25T14:03:11Z",
"enrolledAt": "2026-11-25T14:03:11Z",
"expiresAt": "2026-11-25T14:03:11Z",
"id": "37386ae0-0ea5-44e0-a02e-161f807af560",
"lastActivityAt": "2026-11-25T14:03:11Z",
"learnerEmail": "maya.chen@example.com",
"learnerExternalRef": "string",
"learnerName": "Maya Chen",
"organizationId": "44b78147-d73b-4117-ab62-4292d9ca20db",
"progressPercent": 40,
"source": "ROLE",
"status": "ACTIVE",
"userId": "11f967df-4272-482f-ac0b-7bea76dd8093"
},
"lessons": [
{
"completedAt": "2026-11-25T14:03:11Z",
"lessonId": "3d477cf4-98e8-48b4-a056-a98b308b7364",
"required": false,
"secondsSpent": 120,
"startedAt": "2026-11-25T14:03:11Z",
"status": "ACTIVE",
"title": "Workplace Safety Essentials"
}
]
}Errors
| Status | When |
|---|---|
| 401 | Missing, invalid or expired credentials. |
| 403 | Your credential is valid but isn't allowed to do this. |
| 404 | It doesn't exist, or it belongs to another tenant (the two look the same on purpose). |
Errors use RFC 9457 problem details.
ENROLLMENT_ID=37386ae0-0ea5-44e0-a02e-161f807af560
curl -X GET "$LMS_URL/api/v1/enrollments/$ENROLLMENT_ID" \
-H "X-API-Key: $LMS_KEY"const LMS_URL = process.env.LMS_URL
const LMS_KEY = process.env.LMS_KEY
const enrollmentId = "37386ae0-0ea5-44e0-a02e-161f807af560"
const res = await fetch(`${LMS_URL}/api/v1/enrollments/${enrollmentId}`, {
method: 'GET',
headers: { "X-API-Key": LMS_KEY },
})
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_KEY = process.env.LMS_KEY!
const enrollmentId = "37386ae0-0ea5-44e0-a02e-161f807af560"
const res = await fetch(`${LMS_URL}/api/v1/enrollments/${enrollmentId}`, {
method: 'GET',
headers: { "X-API-Key": LMS_KEY },
})
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 = {"X-API-Key": os.environ["LMS_KEY"]}
enrollment_id = "37386ae0-0ea5-44e0-a02e-161f807af560"
res = requests.get(f"{LMS_URL}/api/v1/enrollments/{enrollment_id}", headers=HEADERS, 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 lmsKey = System.getenv("LMS_KEY");
String enrollmentId = "37386ae0-0ea5-44e0-a02e-161f807af560";
var request = HttpRequest.newBuilder(URI.create(lmsUrl + "/api/v1/enrollments/" + enrollmentId))
.header("X-API-Key", lmsKey)
.method("GET", HttpRequest.BodyPublishers.noBody())
.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 = "37386ae0-0ea5-44e0-a02e-161f807af560"
uri = URI("#{lms_url}/api/v1/enrollments/#{enrollment_id}")
request = Net::HTTP::Get.new(uri, "X-API-Key" => ENV.fetch("LMS_KEY"))
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 = "37386ae0-0ea5-44e0-a02e-161f807af560";
$ch = curl_init("$lmsUrl/api/v1/enrollments/{$enrollmentId}");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['X-API-Key: ' . getenv('LMS_KEY')],
]);
$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"
)
func main() {
enrollmentId := "37386ae0-0ea5-44e0-a02e-161f807af560"
req, _ := http.NewRequest("GET", os.Getenv("LMS_URL") + "/api/v1/enrollments/" + enrollmentId, nil)
req.Header.Set("X-API-Key", os.Getenv("LMS_KEY"))
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))
}Withdraw an enrollment
AccessAdmin, or an API key with the write scope.
Ends the learner's access and releases their license seat. Their progress is kept. Emits enrollment.withdrawn.
Parameters
| Name | In | Type | Notes |
|---|---|---|---|
| idrequired | path | string (uuid) | The id from a previous response. |
Responses
Errors
| Status | When |
|---|---|
| 401 | Missing, invalid or expired credentials. |
| 403 | Your credential is valid but isn't allowed to do this. |
| 404 | It doesn't exist, or it belongs to another tenant (the two look the same on purpose). |
| 409 | Only an active enrollment can be withdrawn. |
Errors use RFC 9457 problem details.
ENROLLMENT_ID=37386ae0-0ea5-44e0-a02e-161f807af560
curl -X DELETE "$LMS_URL/api/v1/enrollments/$ENROLLMENT_ID" \
-H "X-API-Key: $LMS_KEY"const LMS_URL = process.env.LMS_URL
const LMS_KEY = process.env.LMS_KEY
const enrollmentId = "37386ae0-0ea5-44e0-a02e-161f807af560"
const res = await fetch(`${LMS_URL}/api/v1/enrollments/${enrollmentId}`, {
method: 'DELETE',
headers: { "X-API-Key": LMS_KEY },
})
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`)const LMS_URL = process.env.LMS_URL!
const LMS_KEY = process.env.LMS_KEY!
const enrollmentId = "37386ae0-0ea5-44e0-a02e-161f807af560"
const res = await fetch(`${LMS_URL}/api/v1/enrollments/${enrollmentId}`, {
method: 'DELETE',
headers: { "X-API-Key": LMS_KEY },
})
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`)import os
import requests
LMS_URL = os.environ["LMS_URL"]
HEADERS = {"X-API-Key": os.environ["LMS_KEY"]}
enrollment_id = "37386ae0-0ea5-44e0-a02e-161f807af560"
res = requests.delete(f"{LMS_URL}/api/v1/enrollments/{enrollment_id}", headers=HEADERS, timeout=10)
res.raise_for_status()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 lmsKey = System.getenv("LMS_KEY");
String enrollmentId = "37386ae0-0ea5-44e0-a02e-161f807af560";
var request = HttpRequest.newBuilder(URI.create(lmsUrl + "/api/v1/enrollments/" + enrollmentId))
.header("X-API-Key", lmsKey)
.method("DELETE", HttpRequest.BodyPublishers.noBody())
.build();
var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() >= 300) throw new IllegalStateException(response.statusCode() + " " + response.body());
}
}require "net/http"
require "json"
lms_url = ENV.fetch("LMS_URL")
enrollment_id = "37386ae0-0ea5-44e0-a02e-161f807af560"
uri = URI("#{lms_url}/api/v1/enrollments/#{enrollment_id}")
request = Net::HTTP::Delete.new(uri, "X-API-Key" => ENV.fetch("LMS_KEY"))
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)<?php
$lmsUrl = getenv('LMS_URL');
$enrollmentId = "37386ae0-0ea5-44e0-a02e-161f807af560";
$ch = curl_init("$lmsUrl/api/v1/enrollments/{$enrollmentId}");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['X-API-Key: ' . getenv('LMS_KEY')],
]);
$response = curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_RESPONSE_CODE) >= 300) {
throw new RuntimeException($response);
}package main
import (
"fmt"
"io"
"net/http"
"os"
)
func main() {
enrollmentId := "37386ae0-0ea5-44e0-a02e-161f807af560"
req, _ := http.NewRequest("DELETE", os.Getenv("LMS_URL") + "/api/v1/enrollments/" + enrollmentId, nil)
req.Header.Set("X-API-Key", os.Getenv("LMS_KEY"))
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))
}
_ = data
}