Sync users from HR
Keep learner IDs stable when people change teams or names.
Write users before membership
Look up the HR identifier with the id filter. Send revision zero for a new user and the current revision for an update. Wait for the operation to complete before including the user in a group.
curl
curl "$RDC_BASE_URL/elearning/v1/users" \
-H "Authorization: Bearer $RDC_TOKEN" JavaScript
const response = await fetch(`${process.env.RDC_BASE_URL}/elearning/v1/users`, {
method: 'GET',
headers: {
Authorization: `Bearer ${process.env.RDC_TOKEN}`,
},
});
const result = await response.json(); Python
import os
import requests
response = requests.request(
'GET',
f'{os.environ["RDC_BASE_URL"]}/elearning/v1/users',
headers={
'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
},
)
result = response.json() PHP
<?php
$curl = curl_init(getenv('RDC_BASE_URL') . '/elearning/v1/users');
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('RDC_TOKEN'),
],
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl); C#
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/elearning/v1/users");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync(); {
"items": [
{
"id": "radu-ionescu",
"name": "Radu Ionescu",
"department": "logistics",
"revision": 1
}
],
"nextCursor": null
} curl
curl -X POST "$RDC_BASE_URL/elearning/v1/users" \
-H "Authorization: Bearer $RDC_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"operationId": "4e08713a-ec34-4a5a-92d3-81fd42564002",
"expectedRevision": 0,
"id": "radu-ionescu",
"name": "Radu Ionescu",
"department": "logistics"
}' JavaScript
const response = await fetch(`${process.env.RDC_BASE_URL}/elearning/v1/users`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.RDC_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"operationId": "4e08713a-ec34-4a5a-92d3-81fd42564002",
"expectedRevision": 0,
"id": "radu-ionescu",
"name": "Radu Ionescu",
"department": "logistics"
}),
});
const result = await response.json(); Python
import os
import requests
response = requests.request(
'POST',
f'{os.environ["RDC_BASE_URL"]}/elearning/v1/users',
headers={
'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
},
json={
'operationId': '4e08713a-ec34-4a5a-92d3-81fd42564002',
'expectedRevision': 0,
'id': 'radu-ionescu',
'name': 'Radu Ionescu',
'department': 'logistics',
},
)
result = response.json() PHP
<?php
$body = <<<'JSON'
{
"operationId": "4e08713a-ec34-4a5a-92d3-81fd42564002",
"expectedRevision": 0,
"id": "radu-ionescu",
"name": "Radu Ionescu",
"department": "logistics"
}
JSON;
$curl = curl_init(getenv('RDC_BASE_URL') . '/elearning/v1/users');
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('RDC_TOKEN'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => $body,
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl); C#
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/elearning/v1/users");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
"operationId": "4e08713a-ec34-4a5a-92d3-81fd42564002",
"expectedRevision": 0,
"id": "radu-ionescu",
"name": "Radu Ionescu",
"department": "logistics"
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync(); {
"operationId": "4e08713a-ec34-4a5a-92d3-81fd42564002",
"status": "accepted",
"aggregateRevision": null
} curl
curl -X POST "$RDC_BASE_URL/elearning/v1/groups" \
-H "Authorization: Bearer $RDC_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"operationId": "4e08713a-ec34-4a5a-92d3-81fd42564003",
"expectedRevision": 0,
"id": "logistics",
"name": "Logistics",
"userIds": [
"radu-ionescu"
]
}' JavaScript
const response = await fetch(`${process.env.RDC_BASE_URL}/elearning/v1/groups`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.RDC_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"operationId": "4e08713a-ec34-4a5a-92d3-81fd42564003",
"expectedRevision": 0,
"id": "logistics",
"name": "Logistics",
"userIds": [
"radu-ionescu"
]
}),
});
const result = await response.json(); Python
import os
import requests
response = requests.request(
'POST',
f'{os.environ["RDC_BASE_URL"]}/elearning/v1/groups',
headers={
'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
},
json={
'operationId': '4e08713a-ec34-4a5a-92d3-81fd42564003',
'expectedRevision': 0,
'id': 'logistics',
'name': 'Logistics',
'userIds': [
'radu-ionescu',
],
},
)
result = response.json() PHP
<?php
$body = <<<'JSON'
{
"operationId": "4e08713a-ec34-4a5a-92d3-81fd42564003",
"expectedRevision": 0,
"id": "logistics",
"name": "Logistics",
"userIds": [
"radu-ionescu"
]
}
JSON;
$curl = curl_init(getenv('RDC_BASE_URL') . '/elearning/v1/groups');
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('RDC_TOKEN'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => $body,
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl); C#
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/elearning/v1/groups");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
"operationId": "4e08713a-ec34-4a5a-92d3-81fd42564003",
"expectedRevision": 0,
"id": "logistics",
"name": "Logistics",
"userIds": [
"radu-ionescu"
]
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync(); {
"operationId": "4e08713a-ec34-4a5a-92d3-81fd42564003",
"status": "accepted",
"aggregateRevision": null
} Send the full membership list. If a revision conflicts, read the group again and recalculate membership before issuing a new operation.