Docs Guides
Selling and onboarding
From a purchase on your site to learners enrolled, with seats and roles.
This is the flow for selling training to businesses. Payment stays in your system (Stripe, Shopify, anything). You only tell No BS LMS what was bought.
customer pays on your site
└─► your backend: POST /organizations/{id}/licenses
└─► manager invites staff, picking each one's role
└─► staff accept ─► enrolled in their role's courses
One-time setup#
A product is a bundle of courses, linked to your SKU:
curl -X POST "$LMS_URL/api/v1/products" \
-H "X-API-Key: $LMS_KEY" \
-H "Content-Type: application/json" \
-d '{
"slug": "complete-pack",
"name": "Complete Pack",
"externalRef": "SKU-COMPLETE",
"courseIds": [
"4b2e8f90-1d73-4c5a-9e06-a8f1d3b7c254"
]
}'const LMS_URL = process.env.LMS_URL
const LMS_KEY = process.env.LMS_KEY
const res = await fetch(`${LMS_URL}/api/v1/products`, {
method: 'POST',
headers: { "X-API-Key": LMS_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({
"slug": "complete-pack",
"name": "Complete Pack",
"externalRef": "SKU-COMPLETE",
"courseIds": [
"4b2e8f90-1d73-4c5a-9e06-a8f1d3b7c254"
]
}),
})
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/products`, {
method: 'POST',
headers: { "X-API-Key": LMS_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({
"slug": "complete-pack",
"name": "Complete Pack",
"externalRef": "SKU-COMPLETE",
"courseIds": [
"4b2e8f90-1d73-4c5a-9e06-a8f1d3b7c254"
]
}),
})
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/products", headers=HEADERS, json={
"slug": "complete-pack",
"name": "Complete Pack",
"externalRef": "SKU-COMPLETE",
"courseIds": [
"4b2e8f90-1d73-4c5a-9e06-a8f1d3b7c254",
],
}, 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 = """
{
"slug": "complete-pack",
"name": "Complete Pack",
"externalRef": "SKU-COMPLETE",
"courseIds": [
"4b2e8f90-1d73-4c5a-9e06-a8f1d3b7c254"
]
}
""";
var request = HttpRequest.newBuilder(URI.create(lmsUrl + "/api/v1/products"))
.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/products")
request = Net::HTTP::Post.new(uri, "X-API-Key" => ENV.fetch("LMS_KEY"), "Content-Type" => "application/json")
request.body = {
"slug" => "complete-pack",
"name" => "Complete Pack",
"externalRef" => "SKU-COMPLETE",
"courseIds" => [
"4b2e8f90-1d73-4c5a-9e06-a8f1d3b7c254",
],
}.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/products");
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([
"slug" => "complete-pack",
"name" => "Complete Pack",
"externalRef" => "SKU-COMPLETE",
"courseIds" => [
"4b2e8f90-1d73-4c5a-9e06-a8f1d3b7c254",
],
]),
]);
$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(`{
"slug": "complete-pack",
"name": "Complete Pack",
"externalRef": "SKU-COMPLETE",
"courseIds": [
"4b2e8f90-1d73-4c5a-9e06-a8f1d3b7c254"
]
}`)
req, _ := http.NewRequest("POST", os.Getenv("LMS_URL") + "/api/v1/products", 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))
}A role says which courses each kind of person gets:
curl -X POST "$LMS_URL/api/v1/member-roles" \
-H "X-API-Key: $LMS_KEY" \
-H "Content-Type: application/json" \
-d '{
"key": "technician",
"name": "Technician"
}'const LMS_URL = process.env.LMS_URL
const LMS_KEY = process.env.LMS_KEY
const res = await fetch(`${LMS_URL}/api/v1/member-roles`, {
method: 'POST',
headers: { "X-API-Key": LMS_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({
"key": "technician",
"name": "Technician"
}),
})
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/member-roles`, {
method: 'POST',
headers: { "X-API-Key": LMS_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({
"key": "technician",
"name": "Technician"
}),
})
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/member-roles", headers=HEADERS, json={
"key": "technician",
"name": "Technician",
}, 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 = """
{
"key": "technician",
"name": "Technician"
}
""";
var request = HttpRequest.newBuilder(URI.create(lmsUrl + "/api/v1/member-roles"))
.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/member-roles")
request = Net::HTTP::Post.new(uri, "X-API-Key" => ENV.fetch("LMS_KEY"), "Content-Type" => "application/json")
request.body = {
"key" => "technician",
"name" => "Technician",
}.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/member-roles");
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([
"key" => "technician",
"name" => "Technician",
]),
]);
$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(`{
"key": "technician",
"name": "Technician"
}`)
req, _ := http.NewRequest("POST", os.Getenv("LMS_URL") + "/api/v1/member-roles", 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))
}ROLE_ID=164531fc-5f9b-4b3c-9db7-887248454524
curl -X PUT "$LMS_URL/api/v1/member-roles/$ROLE_ID/courses" \
-H "X-API-Key: $LMS_KEY" \
-H "Content-Type: application/json" \
-d '{
"assignments": [
{
"courseId": "4b2e8f90-1d73-4c5a-9e06-a8f1d3b7c254",
"dueAfterDays": 30,
"onRoleRemoved": "KEEP"
}
]
}'const LMS_URL = process.env.LMS_URL
const LMS_KEY = process.env.LMS_KEY
const roleId = "164531fc-5f9b-4b3c-9db7-887248454524"
const res = await fetch(`${LMS_URL}/api/v1/member-roles/${roleId}/courses`, {
method: 'PUT',
headers: { "X-API-Key": LMS_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({
"assignments": [
{
"courseId": "4b2e8f90-1d73-4c5a-9e06-a8f1d3b7c254",
"dueAfterDays": 30,
"onRoleRemoved": "KEEP"
}
]
}),
})
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 roleId = "164531fc-5f9b-4b3c-9db7-887248454524"
const res = await fetch(`${LMS_URL}/api/v1/member-roles/${roleId}/courses`, {
method: 'PUT',
headers: { "X-API-Key": LMS_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({
"assignments": [
{
"courseId": "4b2e8f90-1d73-4c5a-9e06-a8f1d3b7c254",
"dueAfterDays": 30,
"onRoleRemoved": "KEEP"
}
]
}),
})
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"]}
role_id = "164531fc-5f9b-4b3c-9db7-887248454524"
res = requests.put(f"{LMS_URL}/api/v1/member-roles/{role_id}/courses", headers=HEADERS, json={
"assignments": [
{
"courseId": "4b2e8f90-1d73-4c5a-9e06-a8f1d3b7c254",
"dueAfterDays": 30,
"onRoleRemoved": "KEEP",
},
],
}, 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 roleId = "164531fc-5f9b-4b3c-9db7-887248454524";
String body = """
{
"assignments": [
{
"courseId": "4b2e8f90-1d73-4c5a-9e06-a8f1d3b7c254",
"dueAfterDays": 30,
"onRoleRemoved": "KEEP"
}
]
}
""";
var request = HttpRequest.newBuilder(URI.create(lmsUrl + "/api/v1/member-roles/" + roleId + "/courses"))
.header("X-API-Key", lmsKey)
.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")
role_id = "164531fc-5f9b-4b3c-9db7-887248454524"
uri = URI("#{lms_url}/api/v1/member-roles/#{role_id}/courses")
request = Net::HTTP::Put.new(uri, "X-API-Key" => ENV.fetch("LMS_KEY"), "Content-Type" => "application/json")
request.body = {
"assignments" => [
{
"courseId" => "4b2e8f90-1d73-4c5a-9e06-a8f1d3b7c254",
"dueAfterDays" => 30,
"onRoleRemoved" => "KEEP",
},
],
}.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');
$roleId = "164531fc-5f9b-4b3c-9db7-887248454524";
$ch = curl_init("$lmsUrl/api/v1/member-roles/{$roleId}/courses");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['X-API-Key: ' . getenv('LMS_KEY'), 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
"assignments" => [
[
"courseId" => "4b2e8f90-1d73-4c5a-9e06-a8f1d3b7c254",
"dueAfterDays" => 30,
"onRoleRemoved" => "KEEP",
],
],
]),
]);
$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() {
roleId := "164531fc-5f9b-4b3c-9db7-887248454524"
body := strings.NewReader(`{
"assignments": [
{
"courseId": "4b2e8f90-1d73-4c5a-9e06-a8f1d3b7c254",
"dueAfterDays": 30,
"onRoleRemoved": "KEEP"
}
]
}`)
req, _ := http.NewRequest("PUT", os.Getenv("LMS_URL") + "/api/v1/member-roles/" + roleId + "/courses", 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))
}Per purchase#
The customer, once:
curl -X POST "$LMS_URL/api/v1/organizations" \
-H "X-API-Key: $LMS_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Acme Auto",
"externalRef": "cust_123"
}'const LMS_URL = process.env.LMS_URL
const LMS_KEY = process.env.LMS_KEY
const res = await fetch(`${LMS_URL}/api/v1/organizations`, {
method: 'POST',
headers: { "X-API-Key": LMS_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({
"name": "Acme Auto",
"externalRef": "cust_123"
}),
})
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/organizations`, {
method: 'POST',
headers: { "X-API-Key": LMS_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({
"name": "Acme Auto",
"externalRef": "cust_123"
}),
})
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/organizations", headers=HEADERS, json={
"name": "Acme Auto",
"externalRef": "cust_123",
}, 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 = """
{
"name": "Acme Auto",
"externalRef": "cust_123"
}
""";
var request = HttpRequest.newBuilder(URI.create(lmsUrl + "/api/v1/organizations"))
.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/organizations")
request = Net::HTTP::Post.new(uri, "X-API-Key" => ENV.fetch("LMS_KEY"), "Content-Type" => "application/json")
request.body = {
"name" => "Acme Auto",
"externalRef" => "cust_123",
}.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/organizations");
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([
"name" => "Acme Auto",
"externalRef" => "cust_123",
]),
]);
$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(`{
"name": "Acme Auto",
"externalRef": "cust_123"
}`)
req, _ := http.NewRequest("POST", os.Getenv("LMS_URL") + "/api/v1/organizations", 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))
}Then the license, using your order id:
ORGANIZATION_ID=44b78147-d73b-4117-9536-da80f8fe9841
curl -X POST "$LMS_URL/api/v1/organizations/$ORGANIZATION_ID/licenses" \
-H "X-API-Key: $LMS_KEY" \
-H "Content-Type: application/json" \
-d '{
"productId": "8a2c5e71-3b9d-4f06-a1e4-6d7c0b2f9e35",
"seats": 25,
"endsAt": "2027-11-25T00:00:00Z",
"externalRef": "order-5001"
}'const LMS_URL = process.env.LMS_URL
const LMS_KEY = process.env.LMS_KEY
const organizationId = "44b78147-d73b-4117-9536-da80f8fe9841"
const res = await fetch(`${LMS_URL}/api/v1/organizations/${organizationId}/licenses`, {
method: 'POST',
headers: { "X-API-Key": LMS_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({
"productId": "8a2c5e71-3b9d-4f06-a1e4-6d7c0b2f9e35",
"seats": 25,
"endsAt": "2027-11-25T00:00:00Z",
"externalRef": "order-5001"
}),
})
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 organizationId = "44b78147-d73b-4117-9536-da80f8fe9841"
const res = await fetch(`${LMS_URL}/api/v1/organizations/${organizationId}/licenses`, {
method: 'POST',
headers: { "X-API-Key": LMS_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({
"productId": "8a2c5e71-3b9d-4f06-a1e4-6d7c0b2f9e35",
"seats": 25,
"endsAt": "2027-11-25T00:00:00Z",
"externalRef": "order-5001"
}),
})
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"]}
organization_id = "44b78147-d73b-4117-9536-da80f8fe9841"
res = requests.post(f"{LMS_URL}/api/v1/organizations/{organization_id}/licenses", headers=HEADERS, json={
"productId": "8a2c5e71-3b9d-4f06-a1e4-6d7c0b2f9e35",
"seats": 25,
"endsAt": "2027-11-25T00:00:00Z",
"externalRef": "order-5001",
}, 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 organizationId = "44b78147-d73b-4117-9536-da80f8fe9841";
String body = """
{
"productId": "8a2c5e71-3b9d-4f06-a1e4-6d7c0b2f9e35",
"seats": 25,
"endsAt": "2027-11-25T00:00:00Z",
"externalRef": "order-5001"
}
""";
var request = HttpRequest.newBuilder(URI.create(lmsUrl + "/api/v1/organizations/" + organizationId + "/licenses"))
.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")
organization_id = "44b78147-d73b-4117-9536-da80f8fe9841"
uri = URI("#{lms_url}/api/v1/organizations/#{organization_id}/licenses")
request = Net::HTTP::Post.new(uri, "X-API-Key" => ENV.fetch("LMS_KEY"), "Content-Type" => "application/json")
request.body = {
"productId" => "8a2c5e71-3b9d-4f06-a1e4-6d7c0b2f9e35",
"seats" => 25,
"endsAt" => "2027-11-25T00:00:00Z",
"externalRef" => "order-5001",
}.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');
$organizationId = "44b78147-d73b-4117-9536-da80f8fe9841";
$ch = curl_init("$lmsUrl/api/v1/organizations/{$organizationId}/licenses");
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([
"productId" => "8a2c5e71-3b9d-4f06-a1e4-6d7c0b2f9e35",
"seats" => 25,
"endsAt" => "2027-11-25T00:00:00Z",
"externalRef" => "order-5001",
]),
]);
$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() {
organizationId := "44b78147-d73b-4117-9536-da80f8fe9841"
body := strings.NewReader(`{
"productId": "8a2c5e71-3b9d-4f06-a1e4-6d7c0b2f9e35",
"seats": 25,
"endsAt": "2027-11-25T00:00:00Z",
"externalRef": "order-5001"
}`)
req, _ := http.NewRequest("POST", os.Getenv("LMS_URL") + "/api/v1/organizations/" + organizationId + "/licenses", 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))
}externalRef makes the call idempotent: replaying the same order returns the existing license (200) instead of creating another (201). Safe for retried webhooks from your payment provider.
Seats#
seats is yours to set per license (omit for unlimited). Each person with an active enrollment under a license uses one seat; completing or withdrawing releases it. Seats are enforced under a database lock, so two people accepting at once can never exceed the limit.
Inviting people#
ORGANIZATION_ID=44b78147-d73b-4117-9536-da80f8fe9841
curl -X POST "$LMS_URL/api/v1/organizations/$ORGANIZATION_ID/invitations" \
-H "X-API-Key: $LMS_KEY" \
-H "Content-Type: application/json" \
-d '{
"email": "tom@acme.example",
"access": "MEMBER",
"roleId": "2f6a1c93-5d08-4b7e-9a34-c1e8d0f7b625"
}'const LMS_URL = process.env.LMS_URL
const LMS_KEY = process.env.LMS_KEY
const organizationId = "44b78147-d73b-4117-9536-da80f8fe9841"
const res = await fetch(`${LMS_URL}/api/v1/organizations/${organizationId}/invitations`, {
method: 'POST',
headers: { "X-API-Key": LMS_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({
"email": "tom@acme.example",
"access": "MEMBER",
"roleId": "2f6a1c93-5d08-4b7e-9a34-c1e8d0f7b625"
}),
})
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 organizationId = "44b78147-d73b-4117-9536-da80f8fe9841"
const res = await fetch(`${LMS_URL}/api/v1/organizations/${organizationId}/invitations`, {
method: 'POST',
headers: { "X-API-Key": LMS_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({
"email": "tom@acme.example",
"access": "MEMBER",
"roleId": "2f6a1c93-5d08-4b7e-9a34-c1e8d0f7b625"
}),
})
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"]}
organization_id = "44b78147-d73b-4117-9536-da80f8fe9841"
res = requests.post(f"{LMS_URL}/api/v1/organizations/{organization_id}/invitations", headers=HEADERS, json={
"email": "tom@acme.example",
"access": "MEMBER",
"roleId": "2f6a1c93-5d08-4b7e-9a34-c1e8d0f7b625",
}, 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 organizationId = "44b78147-d73b-4117-9536-da80f8fe9841";
String body = """
{
"email": "tom@acme.example",
"access": "MEMBER",
"roleId": "2f6a1c93-5d08-4b7e-9a34-c1e8d0f7b625"
}
""";
var request = HttpRequest.newBuilder(URI.create(lmsUrl + "/api/v1/organizations/" + organizationId + "/invitations"))
.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")
organization_id = "44b78147-d73b-4117-9536-da80f8fe9841"
uri = URI("#{lms_url}/api/v1/organizations/#{organization_id}/invitations")
request = Net::HTTP::Post.new(uri, "X-API-Key" => ENV.fetch("LMS_KEY"), "Content-Type" => "application/json")
request.body = {
"email" => "tom@acme.example",
"access" => "MEMBER",
"roleId" => "2f6a1c93-5d08-4b7e-9a34-c1e8d0f7b625",
}.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');
$organizationId = "44b78147-d73b-4117-9536-da80f8fe9841";
$ch = curl_init("$lmsUrl/api/v1/organizations/{$organizationId}/invitations");
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([
"email" => "tom@acme.example",
"access" => "MEMBER",
"roleId" => "2f6a1c93-5d08-4b7e-9a34-c1e8d0f7b625",
]),
]);
$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() {
organizationId := "44b78147-d73b-4117-9536-da80f8fe9841"
body := strings.NewReader(`{
"email": "tom@acme.example",
"access": "MEMBER",
"roleId": "2f6a1c93-5d08-4b7e-9a34-c1e8d0f7b625"
}`)
req, _ := http.NewRequest("POST", os.Getenv("LMS_URL") + "/api/v1/organizations/" + organizationId + "/invitations", 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))
}Invitations expire after 7 days. The invitee accepts with POST /invitations/accept and the token from the email; a new person also gives a name and password. No account exists until acceptance.
If seats are short at that moment, acceptance is rolled back and the invitation stays pending.
Warning
Email delivery is a stand-in today: messages are logged, not sent. Connect your provider behind the Mailer interface before going live. See Limits and roadmap.
Changing roles later#
Changing a member’s role (or a role’s courses) reconciles enrollments in one transaction. Each assignment’s onRoleRemoved decides whether courses are KEEP-ed or WITHDRAWn.
Individuals#
One person buying for themselves is an organization with kind: INDIVIDUAL and one seat. It uses exactly the same path.