Provisioning users in B12 can be done automatically using B12's API. This API conforms to the SCIM specification. For detailed information about SCIM, see :
- SCIM Overview: https://scim.cloud
- Complete SCIM specification: https://www.rfc-editor.org/rfc/rfc7644
Authorization
Before you can send requests to B12's servers, you need to acquire an access token. Ask Apprentx to generate one for you.
Access tokens give read/write access to one organization within B12. If you need to provision multiple organizations, you will need a different access token for each one of them.
Get user
Get a single user. https://www.rfc-editor.org/rfc/rfc7644#section-3.4.1
GET https://b12.apprentx.rocks/api/scim/v2/Users/{userId}Headers
- Authorization: "Bearer {Access token}"
Params
- userId: The ID of the user to get
Query
None
Body
None
Response
200 OK
{
"schemas": [
"urn:ietf:params:scim:schemas:core:2.0:User",
"urn:ietf:params:scim:schemas:extension:customb12:2.0:User"
],
"id": "12345",
"meta": {
"resourceType": "User",
"created": "2021-03-12T00:52:46.075Z",
"lastModified": "2024-11-26T19:55:00.098Z"
},
"userName": "email@email.com",
"name": {
"formatted": "John Doe",
"familyName": "Doe",
"givenName": "John"
},
"active": true,
"emails": [
{
"value": "email@email.com",
"type": "work",
"primary": true
}
],
"preferredLanguage": "fr-CA",
"roles": [
{
"value": "LEARNER"
}
],
"timezone": "America/Toronto",
"urn:ietf:params:scim:schemas:extension:customb12:2.0:User": {}
}List users
Get many users using filters and pagination. https://www.rfc-editor.org/rfc/rfc7644#section-3.4.2
GET https://b12.apprentx.rocks/api/scim/v2/UsersHeaders
- Authorization: "Bearer {Access token}"
Params
None
Query
| Property | Type | Required | Default | Notes |
| filter | string | https://www.rfc-editor.org/rfc/rfc7644#section-3.4.2.2 | ||
| startIndex | string | 1 | Min. 1 | |
| count | string | 20 | Min. 1, max. 20 |
Body
None
Response
200 OK
{
"schemas": [
"urn:ietf:params:scim:api:messages:2.0:ListResponse"
],
"Resources": [
{
"schemas": [
"urn:ietf:params:scim:schemas:core:2.0:User",
"urn:ietf:params:scim:schemas:extension:customb12:2.0:User"
],
"id": "12345",
"meta": {
"resourceType": "User",
"created": "2021-03-12T00:52:46.075Z",
"lastModified": "2024-04-25T18:11:38.193Z"
},
"userName": "john@email.com",
"name": {
"formatted": "John Doe",
"familyName": "Doe",
"givenName": "John"
},
"active": true,
"emails": [
{
"value": "john@email.com",
"type": "work",
"primary": true
}
],
"preferredLanguage": "fr-CA",
"roles": [
{
"value": "ADMIN"
}
],
"timezone": "America/Toronto",
"urn:ietf:params:scim:schemas:extension:customb12:2.0:User": {}
}
],
"totalResults": 2000,
"startIndex": 1,
"itemsPerPage": 20
}Create user
Create a user in this organization. https://www.rfc-editor.org/rfc/rfc7644#section-3.3
POST https://b12.apprentx.rocks/api/scim/v2/UsersHeaders
- Authorization: "Bearer {Access token}"
Params
None
Query
None
Body
| Property | Type | Required | Default | Notes |
| userName | string | X | Email format | |
| name | object | X | ||
| name.givenName | string | X | ||
| name.familyName | string | X | ||
| active | boolean | true | ||
| emails | array | |||
| emails[x] | object | |||
| emails[x].value | string | X | Email format | |
| preferredLanguage | string | "fr-CA" | "fr-CA" or "en-CA" | |
| timezone | string | "America/Toronto" | IANA format, e.g.: "America/Toronto" | |
| roles | array | [{ value: "LEARNER" }] | ||
| roles[x] | object | |||
| roles[x].value | string | X | ||
| urn:ietf:params:scim:schemas:extension:customb12:2.0:User | object |
Response
Will respond with 409 CONFLICT if the user already exists in this organization. Otherwise:
201 CREATED
{
"schemas": [
"urn:ietf:params:scim:schemas:core:2.0:User",
"urn:ietf:params:scim:schemas:extension:customb12:2.0:User"
],
"id": "12345",
"meta": {
"resourceType": "User",
"created": "2024-12-04T18:31:56.418Z",
"lastModified": "2024-12-04T18:31:56.418Z"
},
"userName": "john@email.com",
"name": {
"formatted": "John Doe",
"familyName": "Doe",
"givenName": "John"
},
"active": true,
"emails": [
{
"value": "john@email.com",
"type": "work",
"primary": true
}
],
"preferredLanguage": "fr-CA",
"roles": [
{
"value": "LEARNER"
}
],
"timezone": "America/Toronto",
"urn:ietf:params:scim:schemas:extension:customb12:2.0:User": {}
}Update user
Update some attributes of a user. https://www.rfc-editor.org/rfc/rfc7644#section-3.5.2
PATCH https://b12.apprentx.rocks/api/scim/v2/Users/{userId}Headers
- Authorization: "Bearer {Access token}"
Params
- userId: The ID of the user to update
Query
None
Body
| Property | Type | Required | Default | Notes |
| schemas | array | X | MUST equal ["urn:ietf:params:scim:api:messages:2.0:PatchOp"] | |
| Operations | array | X | ||
| Operations[x] | object | |||
| Operations[x].path | string | X | https://www.rfc-editor.org/rfc/rfc7644#section-3.5.2 | |
| Operations[x].op | string | X | MUST be "replace" | |
| Operations[x].value | any | X | https://www.rfc-editor.org/rfc/rfc7644#section-3.5.2 |
Response
200 OK
{
"schemas": [
"urn:ietf:params:scim:schemas:core:2.0:User",
"urn:ietf:params:scim:schemas:extension:customb12:2.0:User"
],
"id": "12345",
"meta": {
"resourceType": "User",
"created": "2024-12-04T18:31:56.418Z",
"lastModified": "2024-12-04T18:31:56.418Z"
},
"userName": "john@email.com",
"name": {
"formatted": "John Doe",
"familyName": "Doe",
"givenName": "John"
},
"active": true,
"emails": [
{
"value": "john@email.com",
"type": "work",
"primary": true
}
],
"preferredLanguage": "fr-CA",
"roles": [
{
"value": "LEARNER"
}
],
"timezone": "America/Toronto",
"urn:ietf:params:scim:schemas:extension:customb12:2.0:User": {}
}Delete user
Delete a user from this organization. https://www.rfc-editor.org/rfc/rfc7644#section-3.6
This action cannot be undone. Consider deactivating the user with a PATCH operation instead.
DELETE https://b12.apprentx.rocks/api/scim/v2/Users/{userId}Headers
- Authorization: "Bearer {Access token}"
Params
- userId: The ID of the user to delete
Query
None
Body
None
Response
204 NO CONTENT
{}Errors
In case of an error, a response in the following format will be sent:
404 NOT FOUND
{
"name": "ScimError",
"schemas": [
"urn:ietf:params:scim:api:messages:2.0:Error"
],
"status": "404",
"detail": "User 12345 not found"
}