This article discusses how the Okta API can list users who have been Deactivated by leveraging the Filters option for API calls.
NOTE: Some curl code examples on this page include SSWS API token authentication. However, Okta recommends using scoped OAuth 2.0 and OIDC access tokens to authenticate with Okta management APIs. OAuth 2.0 and OIDC access tokens provide fine-grain control over the bearer's actions on specific endpoints. See Okta API authentication methods for more information. Postman is a third-party tool, and Okta is not responsible for any changes to the application. Support cannot troubleshoot issues with the application itself.
- Universal Directory
- Okta API
- Postman
To obtain a list of deactivated Okta users using the API, a GET request can be made to the Okta Users API with the filter query parameter set to only return deactivated users using either and API client such as Postman or a cURL call.
Using cURL:
Here is an example of a cURL command that can be used to retrieve a list of suspended users:
curl -X GET \ 'https://{OktaDomainName}/api/v1/users?filter=status eq "DEPROVISIONED"' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ -H 'Authorization: SSWS {theAPIkey}'
- In the above command,
{OktaDomainName}should be replaced with the Okta domain, and{theAPIkey}should be replaced with the Okta API token.
The filter parameter retrieves a filtered list of users, specifically those with a deactivated status.
The response will contain a JSON-formatted list of deactivated users, which can be converted into CSV.
Using Postman
-
Prerequisites for Postman:
- Postman is configured for the org environment as described in the Test the Okta REST APIs using Postman article.
- An Okta Org.
- Okta Users API collection imported into Postman.
-
To achieve this, the following procedure is in place:
-
Set up the Postman app as described in the Test the Okta REST APIs using Postman article.
-
Import the Okta Users Collection found on the Okta Users API collection on the Okta developer page.
-
Prepare any of the List Users with a filter API call.
-
On the Params page, change the filter parameter to
status eq "DEPROVISIONED". If the results surpass 25 users, uncheck the limit parameter and press Send. -
Save the Response to a file and convert it to CSV.
-
