API & Webhooks

API Browser Quick Grabs: Bulk Update User’s Enrollment to a Completion


Userlevel 7
Badge +3

This guide is the fifth in a new series of new guides brought to you by @Bfarkas. Links to his other API Browser Quick Grabs guides can be found at the end of this article.

 

A common question is how to mark a large amount of users complete within a course with a certain date. While there are methods to do this from the front-end UI, they can be error prone and take a while as you have to select all the correct users. There is an API endpoint that allows you to update enrollments for a bulk group of users: PUT - /learn/v1/enrollments

 

Before we go further, note that this will only work for cases where the user is already enrolled in the course. If they are not found in the course, the endpoint will return an error and not process the completion status. If you are trying to enroll and mark the user complete in the same action, stay tuned as that is coming in another guide soon.

 

Important Note: The API endpoint we will be using requires a PUT call, meaning it will update and change information on your system. It is highly recommended to test in a sandbox environment before doing this in a production setting. Additionally, it is always advisable to download a backup report of all current statuses, especially completions, prior to performing this API call (just for safety). 

 

 

Getting the Information Together

In order to leverage this endpoint, you will need to gather a few pieces of informationsome easy, others not quite as easy. Some of these can be retrieved in more ways than one, so choose your preferred method for doing so.

 

Docebo User IDs

First and foremost, if you are going to be updating a large amount of users, you need to know which users those are. Ultimately we need this to be a comma separated list of the User Unique IDs.

 

Note: Due to performance considerations, this operation will be capped at 1,000 users per call. You can easily make batches of users and swap them out to quickly unenroll more than 1,000 users.

 

While there are several methods for retrieving these IDs, in this particular case I highly recommend simply making a ‘Users – Courses’ or a ‘Users – Learning Plans’ report, whichever is appropriate. When defining your report, make sure to check the box ‘User Unique ID’ under the User Fields selection area:

 

This will add a column of the exact IDs we need. Use the report to sort/filter/organize your data to identify the users.


When you are ready, we need to convert the column of ‘User Unique IDs’ to a block of comma separated values. There are many ways to do this, so feel free to use your own preference (i.e. concatenating a comma to the end of each row, using TEXTJOIN to merge a defined range, etc.). If you do not have a good or fast way to do this, the easiest is to:
 

  1. Copy the column of ‘User Unique IDs’ that you want to use to your clipboard.

    Note: Skip the heading, we only want the User ID numbers.

     

  2. Go to https://codeshack.io/column-to-comma-separated-list/
     

  3. In the top box, paste the User IDs into it:


     

  4. Scroll down to the bottom box and you will find all the IDs separated by a comma, which is exactly what we want. Copy and paste this in a place you can refer to later (or just leave this webpage open for the time being).

 

Course ID’s

If you are updating the User’s within a Course, you need to know the Docebo Unique ID of the Course. There are three main ways to find this:

 

 Using Reports

The Course Unique ID is available to select under the ‘Course Fields’ area. Simply make sure to select this option when crafting your report and the ID will be easily available to you:

 

 In the Front End

You can also identify individual course IDs directly via the course management area.
 

  1. Navigate to the ‘Course Management’ area in the Admin Menu.
     

  2. Search for and select the course you need the ID of.
     

  3. Look at the URL in the address bar of your browser and the course ID will be found at the end of it:

 

 Using the API Browser

  1. Log into your Docebo instances API Browser by going to: https://<yoursubdomain.docebosaas.com>/api-browser/


     

  2. On the ‘Services’ menu, select ‘course’.
     

  3. Scroll down the left side to find and select the ‘Courses’ category.
     

  4. Select the ‘Returns courses available in the platform’ option.


     

  5. You can adjust the parameter fields as much or as little as you want to help find the courses you are interested in. There are a few I would recommend paying attention to:

    • search_text: Enter text to search the course title and code fields. Only the courses that match the search text you enter will be returned. This is useful to narrow down the plans.

    • type: If you have courses with similar names but are different types, this is useful to make sure you don’t mix them up. I typically use either ‘elearning’ or ‘classroom’ in this field to distinguish between them.

    • status: Similar to the ‘type’ parameter listed above, I like to set this to ‘published’ so that only those courses are returned, but you may want to use different values to distinguish courses. 

    • page_size: This endpoint can have very long lists. To avoid performance issues it will make pages of results. This lets you set how many items show up on a page. By default it is 10 items. The maximum size is 200 items. Enter an appropriate number for your needs here.

    • page: This endpoint can have very long lists. To avoid performance issues it will make pages of results. This field lets you choose which of those pages you view in the output. For example, if you have 50 courses and the page size was set to 20, 3 pages would be generated. When you initially run the endpoint you will see items 1-20. If you put a 2 in this field you will then get items 21-40, a 3 and you’ll get 41-50, etc.
       

  6. Select the ‘OAUTH’ button underneath the options and sign in if you have not done so already.


     

  7. Select the ‘Try’ button.


     

  8. The results will be shown in the middle of the page. The relevant information will be found in the ‘Response Body’ box. The line ‘id’ for each course shown is the ID you are looking for, so make a note of it:

 

 

Note: If you are planning to enter more than one course at a time, you will need the IDs in a list separated by commas (similar to the user IDs). It is easy enough to do this while you are collecting the IDs or, if you used the report technique, you can simply enter them into the conversion website like you did with the user IDs.

 

 

Updating

OK, you have now gathered all the needed information—User IDs and Course IDs. Now it is time to format the information correctly to do the actual call using the API Browser.

 

  1. Log into your Docebo instances API Browser by going to: https://<yoursubdomain.docebosaas.com>/api-browser/

     

  2. On the ‘Services’ menu, make sure ‘learn’ is selected if it is not already.
     

  3. Scroll down the left side to find and select the ‘Enrollment’ category.
     

  4. Select the ‘Update enrollment of users to courses (Multiple update)’ option.

     

  5. Copy the following into the ‘body’ box:

    {

      "user_ids": [

        0

      ],

      "course_ids": [

        0

      ],

      "date_complete": "YYYY-MM-DD HH:MM:SS",

      "status": 2

    }

     

  1. Copy your block of User IDs from above and replace the ‘0’ in the ‘user_ids’ section. Make sure there is no comma on the end or you may receive a syntax error.

    Note: Make sure only 1,000 IDs are placed in here at a maximum. You can easily swap batches of 1,000 users after each call.

     

  2. Replace the ‘0’ under ‘course_ids’ with the course(s) you wish. Make sure there is no comma on the end.
     

  3. In the ‘date_complete’ field, change the ‘YYYY-MM-DD HH:MM:SS’ to the completion date you want reflected on the users’ enrollment record. For example: If I wanted October 31, 2022, I would put: “2022-10-31 12:00:00”.

    Note: There should still be double quotation marks around the date when you enter it.

    Tip: The LMS will consider the date you enter as being in GMT. If you omit the time or make the time close to midnight, the date may be recorded as the previous day when viewing via the UI (depending on your platform’s time zone).
     

    To avoid this issue, I typically enter the time as noon so there is a safe margin. If you care about the precise time being entered, you will need to factor in for the time change. (I hate time 😊)

 

  1. Your setup should look similar to the example below. Here I have 3 users being updated in one course:

     

  2. Select the ‘OAUTH’ button underneath the options and sign in if you have not done so already.

     

  3. Select the ‘Try’ button.

     

  1. The result will show in the middle of the screen in the ‘Response Body’ box. Make sure to review it for potential errors. Each successful update should be noted:

    If there is an error, it will be noted in the response. In the example below, one of the users was not enrolled in the course to begin with and could not be updated:

     

 

That’s it! The users should now be updated to a complete status with the date you provided. If you had more than 1,000 users or need to do batches of users with different completion dates, just swap the appropriate information and hit ‘Try’ again.

 

From looking around the community, there seemed to be a regular need for ongoing management here, so hopefully this helps! The big drawback here is that you can only specify one completion date and the courses apply to all the users in the call. If you need more flexibility, there is a way to achieve this, but it requires the users not to be enrolled to begin with. If this suits your needs more, sit tight and keep an eye out for the next guide in this serieswhere we will cover how to do just that!

 

More API Browser Quick Grabs:

Listing Groups

Bulk Update Course information

Listing Locations

Bulk Unenroll Users from Courses or Learning Plans

Bulk Enroll and Mark User Complete in a Course

Bulk Create Power Users

Bulk Remove Power User Level from Users

 

How do you use the API Browser? Are there any endpoints you don’t understand or use cases you’re looking for input on? Comment below!


12 replies

Userlevel 7
Badge +6

This is the one I was waiting for Brian!!!!! I love that you wrote this up.

It is unfortunate that their isn’t a clean bulk completion loader that we can use. It is a very common UI tool nowadays with systems.

Userlevel 7
Badge +5

This is the one I was waiting for Brian!!!!! I love that you wrote this up.

It is unfortunate that their isn’t a clean bulk completion loader that we can use. It is a very common UI tool nowadays with systems.

The weirdest part is that power users can bulk enroll with CSV in the UI but not even superadmins can bulk complete in the UI. 
 

I think giving power users this ability would be amazing. If they can mark one user complete in the UI they should be able to do it in bulk. 
 

Fantastic guide as always!

Userlevel 7
Badge +6

So in theory there is a bulk complete with the UI - but the problem is that it will be a single date….that dont work for many scenarios. We used it to mark a few people into 3 different session dates/times. But we needed to support it with adding three groups and then filtering on the three groups, selecting all and editing the enrollment for the individuals. It was way too many steps to “land the plane”.

Userlevel 7
Badge +3

This is the one I was waiting for Brian!!!!! I love that you wrote this up.

It is unfortunate that their isn’t a clean bulk completion loader that we can use. It is a very common UI tool nowadays with systems.

Haha, you and about half the PM’s in my inbox……

Your explanation above is spot on, and is probably the number one external ‘tool’ that I get asked how to build from folks regularly. I have it slated for work in Fark.Tools land as well for those who can’t build it on their own, I am curious, would purely a csv upload be the desired behavior for those interested here?

Userlevel 7
Badge +6

That work

 

Haha, you and about half the PM’s in my inbox……

Your explanation above is spot on, and is probably the number one external ‘tool’ that I get asked how to build from folks regularly. I have it slated for work in Fark.Tools land as well for those who can’t build it on their own, I am curious, would purely a csv upload be the desired behavior for those interested here?

Purely a csv will work just fine.

Userlevel 7
Badge +3

That work

 

Haha, you and about half the PM’s in my inbox……

Your explanation above is spot on, and is probably the number one external ‘tool’ that I get asked how to build from folks regularly. I have it slated for work in Fark.Tools land as well for those who can’t build it on their own, I am curious, would purely a csv upload be the desired behavior for those interested here?

Purely a csv will work just fine.

Cool, that’s what is in the current design for enroll/mark complete. Plan is to make it hybrid of enrollment management generally though, but probably will release that component in beta first :)

Userlevel 4

Thanks for this guide @Bfarkas .
Quick Q: can this API call work with Usernames instead of User Unique IDs? 

Userlevel 7
Badge +3

No @GRuss there are very few calls that let you use secondary identifiers in the calls. Reports are your friend here if just trying to do the simple one call since you can add the Docebo ID column to them. 

Userlevel 4

Thanks @Bfarkas , this worked a treat for a one-time bulk course status update task.

I’m curious as to whether the API browser can also be used to bulk update learning plan enrollment validity end dates? A cursory exploration of this only shows the get/retrieve option for this? 

Userlevel 7
Badge +3

Thanks @Bfarkas , this worked a treat for a one-time bulk course status update task.

I’m curious as to whether the API browser can also be used to bulk update learning plan enrollment validity end dates? A cursory exploration of this only shows the get/retrieve option for this? 

Not that I am aware of unfortunately.

Userlevel 5
Badge +1

How about ILT’s I have over 3000 to manually update :(

Userlevel 4

Can this method be used to update the data_expire_validity field? I tried it and got a “bad request” error with the message, “No one of provided user(s) is assigned to provided course(s).” When I run the View Information for Enrolled User Content call using the same info, it responds to the request with the enrollment info which confirms enrollment for the UID and CourseID I supplied.

Reply