API - Creating Audiences (Groups) in Bulk with Postman


Userlevel 6
Badge +2

In my instance we use a lot of groups. Our groups break down into several areas; groups for our vendors (to isolate external companies), groups for our internal organizations, and lastly ad hoc groups created by admins and power users for reporting. Due to a recent re-org I needed to create a lot of groups, and this is how I accomplished it in Postman. 

If you haven’t done so, take the time to go through at least the first two of @Bfarkas Virtual Workshops

https://community.docebo.com/events?tab=past&type=Virtual%20Workshop

This will give you a basic understanding of the API and Postman. Many thanks to Brian Farkas on his hard work and everything that he shared that made this so much simpler.

I had already created groups manually that matched what I needed. In the API explorer I then pulled list of audiences to get the UUID of one of the groups that matched what I needed to make. For this I used the GET /audiences/v1/audience endpoint.

Then I used the UUID from my target audience to get the details about that specific audience using the GET /audiences/v1/audience/{uuid} endpoint.

I then worked in the API explorer to create an audience (group) using the Put /audiences/v1/audience endpoint. Once I had tested that I moved into Postman.

In the example below the audience is based on branch membership (“branch_id”: 1) and a user additional field (“field”: “16”) which houses the organizational unit information. 

I standardized the name, and description of the branches, using a variable for the organizational unit info

  • Audience name = organizational unit name
  • Description = Automatic group - Org Unit = {Org_Unit_Name} + Branch Name
{
"name": "{{Org_Unit_Name}} (Org)",
"description": "Automatic group - Org Unit= {{Org_Unit_Name}} + Internal",
"type": "automatic",
"exclude_deactivated_users": true,
"ruleset": {
"status": "READY",
"operator": "AND",
"sets": [
{
"rules_operator": "AND",
"rules": [
{
"type": "BranchMembership",
"payload": {
"branch_ids": [
1
],
"branch_ids_descendants": [
{
"branch_id": 1,
"descendants": false
}
]
}
},
{
"type": "UserAdditionalField",
"payload": {
"field": "16",
"predicate": {
"text": [
"{{Org_Unit_Name}}"
],
"operator": "equal"
}
}
}
]
}
]
}
}

As described by @Bfarkas in the Virtual Events, I used a variable in the body of the request {{Org_Unit_Name}}.

I then setup a csv file with Org_Unit_Name as the top row, and then each of the values for each my organizational units on each row below that.

As Brian demonstrated, all of these values (header and variables) have to match up to be successful.

In Postman I then right click on the folder that holds my new Create Audience - Org Unit endpoint and select Run Folder. Then I select the csv file with the values (here you can see it named Org.Unit.Names.csv). 

Right click on the folder and select Run Folder

 

Uncheck endpoints you do not want to run, select your file and then select the Run Docebo APIs for Sharing button (so named because I used Brians templates as a starting point). Your button may be different.

The process runs, and then you have your groups.

I went from creating one group in the interface every 3 minutes or so, to creating one group every minute in the API browser using copy & paste from Notepad ++ to creating 60 groups in 1 minute.


2 replies

Userlevel 7
Badge +4

😍GREAT work @dwilburn !

Userlevel 5
Badge +2

Incredible collaboration @dwilburn & @Bfarkas! Wonderful to see your solution and payload illustrated above!

Bookmarked! 😉

Reply