Bulk Delete Mistakenly Imported Okta Users
Last Updated:
Overview
An incorrect import process populates the Okta directory with unwanted user accounts from incorrect Organizational Units (OUs). Resolve this issue by using the Rockstar browser extension or the Okta API to download a report of all imported users from a specific date, and then bulk-delete them using an API client.
Applies To
- Okta Identity Engine (OIE)
- Okta Classic Engine
- User Management
- Directories
- Application Programming Interface (API)
Cause
An administrator accidentally imports users from incorrect Organizational Units (OUs) into Okta.
Solution
How does the Rockstar browser extension identify and export mistakenly imported users?
Install the Rockstar browser extension, navigate to the Okta directory, and execute a search query to export a Comma-Separated Values (CSV) file containing the mistakenly imported users.
- Install the Rockstar Browser Extension.
- Navigate to Directory > People and click Export Users in the Rockstar pop-up menu.
- Enter the following query in the Query, Filter, or Search field to search for users created on a specific date:
search=created ge "2026-07-07T00:00:00.000Z" and created lt "2026-07-08T00:00:00.000Z"
NOTE: Adjust the dates in the query to reflect when the unwanted users were created or imported into Okta. Thegeparameter includes every user created on or after the beginning of the specified date. Theltparameter excludes any user created once the following date begins, capturing the entire 24-hour block. TheZparameter ensures the query uses Coordinated Universal Time (UTC).
- Click Export to download the CSV report containing all users created on the specified date and time.
Deactivate and Delete the Exported Users Using an API Client
Configure an API client (for example, Postman) to send POST and DELETE requests to the Okta API, and run a collection using the exported CSV file to bulk deactivate and delete the users. Ensure the selected tool fits the organization's guidelines.
- Open an API client and create a new request in the Okta workspace.
- Set the method to POST and the URL to:
{{url}}/api/v1/users/{{Username}}/lifecycle/deactivate - Ensure the API client environment contains the properly configured Okta API token and URL.
- Set the following Headers: Accept:
application/json, Content-Type:application/json, and Authorization:SSWS {{api_token}}. - Save this request into a new folder or collection named Okta Cleanup or Bulk Delete Users, and title the request Deactivate bulk users.
- Create another request, set the method to DELETE, and set the URL to:
{{url}}/api/v1/users/{{Username}} - Ensure the request uses the same headers and save the request to the same collection as the previous step, titling it Delete Bulk Users.
- Select the Okta Cleanup or Bulk Delete Users folder on the left side menu of the API client.
- Click the Run button.
- Click Select File on the right side of the new runner window and select the previously exported CSV file.
- Click Run Bulk Delete Users to deactivate and delete the users listed in the CSV file. The API client displays the following results:
- Verify the removal of the users in the Admin Console or check the System Log using the following query:
eventType eq "user.lifecycle.delete.completed"
