Deleting Delegates from the UI using API

Hello Everybody.

Introduction

This article walks you through the details of how to use the below mentioned API end point to delete Delegates from the UI.

Summary

Using the below mentioned Curl API endpoint it is possible to delete a delegate from the Harness UI through automation. The two details you need to provide to it are the Delegate ID & Bearer Token which will be used to run the deletion.

curl 'https://app.harness.io/gateway/api/setup/delegates/<Delegate ID>?accountId=jDOmhrFmSOGZJ1C91UC_hg&forceDelete=true' \
  -X 'DELETE' \
  -H 'authority: app.harness.io' \
  -H 'accept: application/json' \
  -H 'authorization: Bearer <Token>' \
  -H 'content-type: application/json; charset=utf-8' \
  --compressed

The only pre-requisite needed here is to ensure that the Delegate we are passing to the API to delete is a disconnected one and not one which is connected.

This is because we have a validation in place which can be seen in the UI as well where when we try to delete a delegate Harness asks to validate that this is a delegate which will no longer be required by the account.

In cases where the Delegate is already in a disconnected state the validation is skipped as it is no longer running meaning it will not be actively picking up any tasks.

1 Like