Skip to content

Script to remove teams with no boards using the Miro REST API

Notifications You must be signed in to change notification settings

miroapp/delete-empty-teams-rest-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 

Repository files navigation

Miro - Delete Empty Teams Script via API (Node.js)

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).

Disclaimer

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.

Requirements

  • 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.

Step 1. Install Node.js

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).

Step 2. Create directory for your script files

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.

Step 3. Create a Developer Team in Miro

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.

Step 4. Make sure you have the "Content Admin" Role in 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.

Step 5. Create a Miro App to get a REST API Token

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.

Accept app terms screenshot

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.

Create app screenshot

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

API token scopes

5.4. Click on Install app and get OAuth token

Install and and get token screenshot

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

Install and and get token screenshot

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.

Install and and get token screenshot

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

Install and and get token screenshot

Step 6. Run script deleteEmptyTeams.js using the command line (CLI)

6.1. Within the file node deleteEmptyTeams.js replace the values of the below variables at the top of the script:

  • IS_TEST: set to true to run the script in test mode (no deletions will occur only reports will be generated). Set to false to perform the Miro Team deletions - code line 10
  • TOKEN: replace value with your REST API token from step 5.6 - code line 11
  • MIRO_ORGANIZATION_ID: replace value with your Miro Organization ID from step 5.7 - code line 12

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.

Step 7. Review the folder miro_teams_deletion_output_files

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 file
  • Miro_Teams_Deletion_Results.json: Contains the results of the team deletions in a JSON file
  • Miro_Teams_Overview.csv: Contains an overview of all teams within the Miro account in a .CSV file
  • Miro_Teams_Overview.json: Contains an overview of all teams within the Miro account in a JSON file
  • Miro_Teams_to_Delete.csv: Contains the empty teams to be deleted in a .CSV file
  • Miro_Teams_to_Delete.json: Contains the empty teams to be deleted in a JSON file
  • Script_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 present
  • Script_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

Support

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.

About

Script to remove teams with no boards using the Miro REST API

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published