curl --request POST \
--url https://myorg.tribalhabits.com/papi/topic_assignments \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"user_name": "user1@example.com",
"enrolment_code_1": "TH-4-77-NEW",
"enrolment_code_1_due_date": "31/12/2021"
}
'import requests
url = "https://myorg.tribalhabits.com/papi/topic_assignments"
payload = {
"user_name": "user1@example.com",
"enrolment_code_1": "TH-4-77-NEW",
"enrolment_code_1_due_date": "31/12/2021"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
user_name: 'user1@example.com',
enrolment_code_1: 'TH-4-77-NEW',
enrolment_code_1_due_date: '31/12/2021'
})
};
fetch('https://myorg.tribalhabits.com/papi/topic_assignments', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://myorg.tribalhabits.com/papi/topic_assignments",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'user_name' => 'user1@example.com',
'enrolment_code_1' => 'TH-4-77-NEW',
'enrolment_code_1_due_date' => '31/12/2021'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}using RestSharp;
var options = new RestClientOptions("https://myorg.tribalhabits.com/papi/topic_assignments");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "<api-key>");
request.AddJsonBody("{\n \"user_name\": \"user1@example.com\",\n \"enrolment_code_1\": \"TH-4-77-NEW\",\n \"enrolment_code_1_due_date\": \"31/12/2021\"\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
require 'uri'
require 'net/http'
url = URI("https://myorg.tribalhabits.com/papi/topic_assignments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"user_name\": \"user1@example.com\",\n \"enrolment_code_1\": \"TH-4-77-NEW\",\n \"enrolment_code_1_due_date\": \"31/12/2021\"\n}"
response = http.request(request)
puts response.read_body{
"assignments": [
{
"id": 12345,
"created_at": "2019-04-01T18:03:15.966+11:00",
"updated_at": "2020-01-22T14:38:39.099+11:00",
"completed_topic_at": "2019-10-23T15:27:09.829+11:00",
"status": "Conquered",
"due_date": null,
"relationship": "reader",
"conquered_minutes": 7,
"conquered_cpd_minutes": 7,
"enrolled_by": "Upload people enrolment by API",
"certified_date": null,
"recertification_allowed": true,
"version": null,
"skills_attained": [
{
"id": 13,
"name": "First Aid"
}
],
"categories": [
{
"name": "Health",
"minutes": 39.5,
"points": 500
}
],
"person": {
"id": 2,
"name": "User One",
"user_name": "user1@example.com",
"link": "/people/users/7"
},
"topic": {
"id": 3,
"title": "Confident and effective business networking",
"link": "/knowledge/topics/3/overview",
"knowledge_type": 0,
"show_certificate": true,
"external_id": "123"
}
}
]
}{
"errors": [
"'TH-4-999' does not correspond to a known topic or pathway"
]
}{
"errors": [
"Cannot find user"
]
}{
"error": "Rate limit exceeded. Please slow down.",
"retry_after_seconds": 23
}Create or update topic or pathway enrolments
This endpoint creates or updates topic or pathway enrolments for one user, using enrolment codes. It is the single endpoint for creating and updating all enrolments, including pathway enrolments. Use the UPDATE action code to change dates on an existing enrolment. See How can I enrol people or import enrolments via a spreadsheet (CSV) for an explanation of enrolment codes.
Up to 5 enrolments can be given, using the enrolment_code_N fields where N is from 1..5.
The response lists the user’s current enrolment for each code. For pathway codes, each item has the pathway enrolment fields instead. If any code or date is invalid, 400 is returned with a list of errors, for example {"errors":["'TH-4-999' does not correspond to a known topic or pathway"]}. If the user cannot be found, 404 is returned with {"errors":["Cannot find user"]}.
curl --request POST \
--url https://myorg.tribalhabits.com/papi/topic_assignments \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"user_name": "user1@example.com",
"enrolment_code_1": "TH-4-77-NEW",
"enrolment_code_1_due_date": "31/12/2021"
}
'import requests
url = "https://myorg.tribalhabits.com/papi/topic_assignments"
payload = {
"user_name": "user1@example.com",
"enrolment_code_1": "TH-4-77-NEW",
"enrolment_code_1_due_date": "31/12/2021"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
user_name: 'user1@example.com',
enrolment_code_1: 'TH-4-77-NEW',
enrolment_code_1_due_date: '31/12/2021'
})
};
fetch('https://myorg.tribalhabits.com/papi/topic_assignments', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://myorg.tribalhabits.com/papi/topic_assignments",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'user_name' => 'user1@example.com',
'enrolment_code_1' => 'TH-4-77-NEW',
'enrolment_code_1_due_date' => '31/12/2021'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}using RestSharp;
var options = new RestClientOptions("https://myorg.tribalhabits.com/papi/topic_assignments");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "<api-key>");
request.AddJsonBody("{\n \"user_name\": \"user1@example.com\",\n \"enrolment_code_1\": \"TH-4-77-NEW\",\n \"enrolment_code_1_due_date\": \"31/12/2021\"\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
require 'uri'
require 'net/http'
url = URI("https://myorg.tribalhabits.com/papi/topic_assignments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"user_name\": \"user1@example.com\",\n \"enrolment_code_1\": \"TH-4-77-NEW\",\n \"enrolment_code_1_due_date\": \"31/12/2021\"\n}"
response = http.request(request)
puts response.read_body{
"assignments": [
{
"id": 12345,
"created_at": "2019-04-01T18:03:15.966+11:00",
"updated_at": "2020-01-22T14:38:39.099+11:00",
"completed_topic_at": "2019-10-23T15:27:09.829+11:00",
"status": "Conquered",
"due_date": null,
"relationship": "reader",
"conquered_minutes": 7,
"conquered_cpd_minutes": 7,
"enrolled_by": "Upload people enrolment by API",
"certified_date": null,
"recertification_allowed": true,
"version": null,
"skills_attained": [
{
"id": 13,
"name": "First Aid"
}
],
"categories": [
{
"name": "Health",
"minutes": 39.5,
"points": 500
}
],
"person": {
"id": 2,
"name": "User One",
"user_name": "user1@example.com",
"link": "/people/users/7"
},
"topic": {
"id": 3,
"title": "Confident and effective business networking",
"link": "/knowledge/topics/3/overview",
"knowledge_type": 0,
"show_certificate": true,
"external_id": "123"
}
}
]
}{
"errors": [
"'TH-4-999' does not correspond to a known topic or pathway"
]
}{
"errors": [
"Cannot find user"
]
}{
"error": "Rate limit exceeded. Please slow down.",
"retry_after_seconds": 23
}Authorizations
Your organisation's API key, sent as Authorization: my_api_key. The key can also be passed as an api_key query parameter. See Authentication.
Body
User name identifier (case-insensitive). Required, unless user_id is supplied instead
The internal user ID (person.id). Alternative to user_name
The enrolment code, eg TH-4-77-NEW. If no codes are given, an empty assignments list is returned
When the enrolment is due. Formats: 'yyyy-mm-dd', 'dd/mm/yyyy' or 'dd/mm/yy'
When the enrolment was conquered (completed), used with completion codes. Same formats
When the enrolment is certified up to. Same formats
Skill names attained, separated with a semicolon
The enrolment code, eg TH-4-77-NEW
When the enrolment is due. Formats: 'yyyy-mm-dd', 'dd/mm/yyyy' or 'dd/mm/yy'
When the enrolment was conquered (completed), used with completion codes. Same formats
When the enrolment is certified up to. Same formats
Skill names attained, separated with a semicolon
The enrolment code, eg TH-4-77-NEW
When the enrolment is due. Formats: 'yyyy-mm-dd', 'dd/mm/yyyy' or 'dd/mm/yy'
When the enrolment was conquered (completed), used with completion codes. Same formats
When the enrolment is certified up to. Same formats
Skill names attained, separated with a semicolon
The enrolment code, eg TH-4-77-NEW
When the enrolment is due. Formats: 'yyyy-mm-dd', 'dd/mm/yyyy' or 'dd/mm/yy'
When the enrolment was conquered (completed), used with completion codes. Same formats
When the enrolment is certified up to. Same formats
Skill names attained, separated with a semicolon
The enrolment code, eg TH-4-77-NEW
When the enrolment is due. Formats: 'yyyy-mm-dd', 'dd/mm/yyyy' or 'dd/mm/yy'
When the enrolment was conquered (completed), used with completion codes. Same formats
When the enrolment is certified up to. Same formats
Skill names attained, separated with a semicolon
Response
The user's current enrolment for each code
- Topic enrolment
- Pathway enrolment
Show child attributes
Show child attributes

