This repository contains a script in JavaScript/Node.js to delete empty Miro teams using Miro's REST API.
The script provides a TEST MODE flag to run it without performing any changes. (See step 6 further below).
The content of this project is subject to the Miro Developer Terms of Use: https://miro.com/legal/developer-terms-of-use/
This script is provided as an example to illustrate how to identify Miro Teams with no Boards within and to remove these empty Teams.
The usage of this script is at the sole discretion and responsibility of the customer and is to be tested thoroughly before running it on Production environments.
- NodeJS 16.x or higher installed
- You must be a Company Admin in your Miro account, or at least the user generating the token must be a Company Admin in your Miro account (see steps 3 to 5)
- You must have the role Content Admin assigned, or at least the user generating the token must have the role Content Admin assigned (see step 4 below)
Note: If the person running the script is not a Company Admin with the Content Admin role in your organization's Miro account, please have a Company Admin with the Content Admin role in your Miro account follow the steps 3 to 5. Once the token has been created, the Miro Company Admin with the Content Admin role can provide the token to the user who will run the scripts to execute the changes.
1.1. If you already have Node.js installed in your local machine, you may skip this step.
1.2. If you do not have Node.js installed, proceed to download it here and proceed to install Node with the downloaded file. (Feel free to use the command line to download and install Node if preferred).
2.1. In your local machine create a folder in the desired location where you will store the files within this repository.
2.2. Download this repository as .zip and extract the files within into the directory created, or clone this repository into the desired location in your local machine.
3.1. If you already have a Miro Developer Team, you may skip this step.
3.2. If you do not have yet a Miro Developer Team, please visit this Miro Help page and follow the instructions within the article to create an Enterprise Developer Team for your Miro Enterprise Account.
4.1. To be able to check the true number of Boards within your Miro Enterprise Account (including Boards you have not been invited to) you need to have the role "Content Admin" assigned. To check this, proceed as explained in this Miro Help article.
4.2. If you do not appear within the users assigned to the "Content Admin" role, proceed to add yourself to the "Content Admin" users as explained in the Help article mentioned in step 4.1.
5.1. To create a new application on your Miro Enterprise account using the Enterprise Developer team, navigate to Profile settings > Your apps, agree to the terms and conditions, and click on + Create new app.
5.2. Insert the desired app name (e.g. Delete Empty Teams Script), select your Developer team for the application and click on Create app.
5.3. On the app page, scroll down and select the following scopes of access to grant to your REST API token:
boards:read
organizations:teams:read
organizations:teams:write
5.4. Click on Install app and get OAuth token
5.5. Select any Production team within your Enteprise account, the token will apply for the entire account based on the scopes set on step 5.3 and click on Add
5.6. You will see the REST API token. Copy this token and store it in a secure place. You will need it when running the scripts.
5.7. Find your Miro Organization ID as you will need it when running the scripts. You will find your Miro Organization ID in the URL of the page where you received the REST API token
6.1. Within the file node deleteEmptyTeams.js
replace the values of the below variables at the top of the script:
IS_TEST
: set totrue
to run the script in test mode (no deletions will occur only reports will be generated). Set tofalse
to perform the Miro Team deletions - code line10
TOKEN
: replace value with your REST API token from step 5.6 - code line11
MIRO_ORGANIZATION_ID
: replace value with your Miro Organization ID from step 5.7 - code line12
6.2. Save your changes.
6.3. In your command line interface navigate to the directory where you have placed the script files (see step 2.2)
6.4. In your command line interface run node deleteEmptyTeams.js
. This command will trigger the script.
Within the same folder where this script lives, the script creates a folder called miro_teams_deletion_output_files
. Within this folder you will find the below reports:
Miro_Teams_Deletion_Results.csv
: Contains the results of the team deletions in a .CSV fileMiro_Teams_Deletion_Results.json
: Contains the results of the team deletions in a JSON fileMiro_Teams_Overview.csv
: Contains an overview of all teams within the Miro account in a .CSV fileMiro_Teams_Overview.json
: Contains an overview of all teams within the Miro account in a JSON fileMiro_Teams_to_Delete.csv
: Contains the empty teams to be deleted in a .CSV fileMiro_Teams_to_Delete.json
: Contains the empty teams to be deleted in a JSON fileScript_Errors.csv
: Contains API errors (if any) in a CSV file. This report is created only if errors occurred, otherwise the file will not be presentScript_Errors.json
: Contains API errors (if any) in a JSON file. This report is created only if errors occurred, otherwise the file will not be present
If you have any questions or need assistance setting up this application, please reach out to your Miro Customer Success Manager, Onboarding Consultant, Technical Architect or dedicated Miro Solutions Engineer.