
GuyS.49159 (Customer) asked a question.
Hello,
I have a script that creates a user for tests. It adds them to a "test user" group that I created. I added a workflow that deactivates all inactive users (after the test is over, 1 day after they will count as inactive, so this is good enough for me) from the "test user" group, which is great. Now I am wondering if there's a way to actually just delete those users? Sadly, the workflow says it will "delete" but it simply deactivates them. I previously asked a question about whether those deactivated users will count towards the 10,000 per month user quota and been told that since they are deactivated, they don't count, but to be sure i'd still like to delete them instead. Is there a way to delete all users from a group / all deactivated users from a group / just all deactivated users in general on a regular basis?

I believe this will help you with what you are trying to accomplish.
https://support.okta.com/help/s/article/How-to-Perform-a-Bulk-Delete-of-Okta-Users-With-API?language=en_US
Hello JohnPaul. That process is manual - it requires getting the csv, parsing it and using postman to delete. I am wondering if there's a more automated process. At the very least, maybe an API that could help me with that (delete all users from group or something).
There is a script provided in that link that you can run as a scheduled task to delete the user. You'll just need to add a command to the script to create the csv file. Something similar to this:
oktaListDeprovisionedUsers | where lastupdated -lt $30days | select status, lastupdated -ExpandProperty profile | select login
@GuyS.49159 (Customer) I'm very interested in that too, you would think that would be an out of the box use case with the workflows templates...
"Deleting" a user is staged just like if you were manually doing it through the GUI. To delete a user you have to deactivate them first (one API call) then delete them (second API call)
See the API documentation for Delete User: https://developer.okta.com/docs/reference/api/users/#response-example-29
So if you were to make a flow it would look something like:
1). Locate all users meeting X criteria (in your case inactive)
2). Use a "for each" to call a child flow
3). In the child flow perform a deactivate, then a delete
Hi Guys,
You could use Okta's card "List Group Members" with function card "For each". Then in your child flow you implement your logic, meaning 2 cases (I keep it simple): If account status is "active" then run an API call for deactivation and deletion. Else If account is "Deprovisioned" run API call for deletion.