How to delete all webhooks in bulk?
There is an api end point to delete webbooks one by one.. any end point to delete all in once?
Hi @Sunil Patel
You're correct, deleting webhooks (see here) is not one of the supported bulk operations; you would need to write a script to loop through them all.
Here is a python script to loop through and delete all inactive webhooks. If you want to delete all active webhooks, change the line if j['data'][x]['enabled'] == False: to if j['data'][x]['enabled'] == True:
If you want to delete both inactive and active webhooks, take out that line all together.
Is it well written? Probably not. But it gets the job done.
Note: the 'whArray' will print twice. One will the IDs of all inactive webhooks. The second time should print blank if successful. This will also create a file titled 'SSwebhookdata.json' that contains all the data for the webhooks. Was this necessary? Probably not but it's the only thing I could get to work.
import smartsheet import requests import json smartsheet_client = smartsheet.Smartsheet('SMARTSHEET TOKEN HERE') IndexResult = smartsheet_client.Webhooks.list_webhooks( page_size=100, page=1, include_all=False) results = str(IndexResult) response = json.loads(results) with open('SSwebhookdata.json', 'w') as f: json.dump(response, f) with open('SSwebhookdata.json', 'r') as string: my_dict=json.load(string) string.close() j = my_dict x = -1 indexArray =  whArray =  for each in j['data']: x += 1 indexArray.append(x) for x in indexArray: if j['data'][x]['enabled'] == False: whArray.append(j['data'][x]['id']) print(whArray) def deleteWH(): smartsheet_client.Webhooks.delete_webhook() for each in whArray: smartsheet_client.Webhooks.delete_webhook(each) print(whArray) print(IndexResult)