Best Answer

Delete Multiple Branches

  • 23 February 2024
  • 2 replies
  • 51 views

Userlevel 3
Badge

Hello all!

I’m looking to do some clean up of my branches.  I had preemptively created several branches with a mass upload for our client users.  After 3 years, I’m looking to remove any branches that are still empty.

  1. Is there a report or a way to quickly identify all branches without users?
  2. is there a way to do a mass delete of these empty branches?  Possibly including running an API

Thanks!

icon

Best answer by elamast 23 February 2024, 17:02

View original

2 replies

Userlevel 7
Badge +7

Not sure that a user report would should you the empty branches and since there is no real ‘branch report” it may still require some manual effort.

found this set if Apis but not sure it’s what you need:

https://doceboapi.docebosaas.com/api-browser/#!/report/BranchDashboardEnrollment/BranchDashboardEnrollment_report_v1_branch_dashboard_enrollment_id_view

Userlevel 6
Badge +2

Using your favorite automation tool, this will get you all of your branches and descendants:

https://YOURDOMAIN/manage/v1/orgchart?search_type=1&flattened=true

For each branch ID returned, you would want to retrieve the number of users:

https://YOURDOMAIN/manage/v1/orgchart/BRANCHNUMBER/users?page_size=1

The “page_size=1” parameter will return a single user (in order to limit the amount of data returned). The only part of the return you’re interested in is under the JSON path data.total_count

This will provide you with the number of users for that branch including subbranches.  You’re looking for that number to be zero.  At that point you could use the Batch deletion of branches endpoint to remove them this way:

https://YOURDOMAIN/manage/v1/orgchart/batch

{

  "items": [

    {

      "id": BRANCHNUMBER

    }

  ]

}

Reply