# Disable Accounts in bulk using Workflows

**URL:** <https://developer.sailpoint.com/discuss/t/disable-accounts-in-bulk-using-workflows/7143>\
**Category:** SHF Discussion and Questions\
**Tags:** workflows, sailpoint-identity-security\
**Created:** [December 13, 2022, 9:40am UTC](https://developer.sailpoint.com/discuss/t/disable-accounts-in-bulk-using-workflows/7143 "2022-12-13T09:40:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![v\_sowmithri](https://avatars.discourse-cdn.com/v4/letter/v/a587f6/32.png) [@v\_sowmithri](https://developer.sailpoint.com/discuss/u/v_sowmithri)\
**Post date:** [December 13, 2022, 9:40am UTC](https://developer.sailpoint.com/discuss/t/disable-accounts-in-bulk-using-workflows/7143/1 "2022-12-13T09:40:55Z")

</div>

Hello All,

We have about 3K+ accounts on a source to be disabled. Is there a way to do it using the Workflow feature and if yes, can you please kick start me with some ideas. Thank you.

Best Regards,  
Sowmithri V

---

<div class="post-metadata">

**Author:** ![colin\_mckibben](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/colin_mckibben/32/37182_2.png) [@colin\_mckibben](https://developer.sailpoint.com/discuss/u/colin_mckibben)\
**Post date:** [December 15, 2022, 3:05pm UTC](https://developer.sailpoint.com/discuss/t/disable-accounts-in-bulk-using-workflows/7143/2 "2022-12-15T15:05:30Z")

</div>

Workflows really shines when you want to perform a series of actions based on an event that happens in IdentityNow. If this is a one-off action that you need to perform irregularly, then you would probably be better off writing a script in a language like Python that utilizes the [list accounts API](https://developer.sailpoint.com/idn/api/v3/list-accounts) to get all accounts for a given source, and then [disable account API](https://developer.sailpoint.com/idn/api/v3/disable-account) to do the disabling.

This script should work out of the box. The command that actually disables the accounts is commented out so you can do a test run first to make sure the accounts are correct. When you are ready to actually disable them, just uncomment the last line.

```json
import requests
import json

# Populate these three variables with your details
tenant = "devrel"
accessToken = ""
sourceId = "2c9180877de347a1017e21d505831cd4"

headers = {
  'Accept': 'application/json',
  'Authorization': f'Bearer {accessToken}'
}

url = f'https://{tenant}.api.identitynow.com/v3/accounts?filters=sourceId eq "{sourceId}"&limit=250'
offset = 0

response = requests.request("GET", url + f'&offset={offset}', headers=headers).json()

accounts = response

while len(response) == 250:
    offset += 250
    response = requests.request("GET", url + f'&offset={offset}', headers=headers).json()
    accounts = accounts + response

for account in accounts:
    url = f'https://{tenant}.api.identitynow.com/v3/accounts/{account["id"]}/disable'
    print(f'Disable account {account["id"]}: {account["name"]}')
    #response = requests.request("POST", url, data=json.dumps({}), headers=headers).json()

```

You’ll need to install the `requests` module first if you don’t have it. You can install it by running

```auto
pip install requests

```

Then, save this script to a file called `disable-accounts.py` and run it.

```auto
python disable-accounts.py

```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/sailpoint/original/2X/f/f2136700ed5e3703e0b85e02f6be799dacca7735.png) [@system](https://developer.sailpoint.com/discuss/u/system)\
**Post date:** [July 19, 2023, 2:23pm UTC](https://developer.sailpoint.com/discuss/t/disable-accounts-in-bulk-using-workflows/7143/3 "2023-07-19T14:23:59Z")

</div>

Closed on July 19, 2023, 2:23pm UTC


