TeamViewer (Classic) provides a web-based API that allows you to access data and control various aspects of your TeamViewer account. You can use the API to develop apps that integrate TeamViewer functionality into your corporate environment or develop apps that everyone can use.

This article applies to all users.


Imagine that you need to remove a group with devices inside, one by one, and then delete a group. That’s OK when you have a couple of devices, but when you have hundreds may be a hassle. Let’s take advantage of the API technology by creating a script that will automatically delete a group for you, including devices inside of it. All you need to do provide the API token and the group name. This article will show you how.

From a detailed perspective, we will be using the Group Management and Device Management API functions. Windows PowerShell was used to implement the solution. Using a user token, the code will retrieve the devices and groups from your management console, display them and let you choose what group you want to delete. After making the selection, the result will be a neat console.

How to get started

Make sure you have a TeamViewer account. If you don’t have one, you may get one free at

To create a script, please log in to the TeamViewer (Classic) Management Console with your TeamViewer account and create a script token.

In the Console, open your profile settings in the top right of the website. Then select Apps and click Create script token. Complete the form to define your token

• Enter your script name

• Enter a description for your script token

• Choose the permissions of your script token

• Group Management – View, create, delete edit, and share groups

• Computers & Contacts – View, add, edit and delete entries

• Save the script token

Now, save the token in a safe place. This will be requested by the script when it’s running.

The Code

$token = Read-Host -Prompt "Paste your account token code here"
$bearer = "Bearer",$token

$header = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$header.Add("authorization", $bearer)

$webrequest = Invoke-RestMethod -Uri "" -Method Get -Headers $header
$machine = Invoke-RestMethod -Uri "Https://" -Method Get -Headers $header

$grpArr = @()

ForEach($grp in $webrequest.groups)
    Write-Host $i ")" $ " - " $
    $grpArr += $;
    ForEach($dev in $machine.devices)
        If($dev.groupid -eq  $
            Write-Host "     " $dev.alias
    $i += 1
$ig = Read-Host -Prompt "Select the group you will like to remove"

ForEach ($dgrp in $machine.devices)
    if($dgrp.groupid -eq $grpArr[$ig - 1])
        Write-Host "Delete device: " $dgrp.alias
        $item = $dgrp.device_id
        $delete = Invoke-WebRequest -Uri "Https://$item" -Method Delete -Headers $header

Write-Host "Delete group id: " $grpArr[$ig - 1] 
   $gid = $grpArr[$ig - 1]
   $remove = Invoke-WebRequest -Uri "Https://$gid" -Method Delete -Headers $header 


How to run the script

Copy the script code into your favorite text editor (ex. Notepad), and save as .ps1 file. (test.ps1)


Please watch the following video for detailed information on how the script works.

The Bottom Line

TeamViewer (Classic) API is valuable when you need to get the most from your management console. By combining this with a programming language and your imagination, you might get instant results like this for your everyday tasks. Enjoy!