This article addresses the following question:
- Is it possible to use the Okta API to list users who are a certain status in Okta, suck as Locked Out, Deactivated, etc., by leveraging the Filters option for API calls?
NOTE: Some of the 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.
- Universal Directory
- Okta API
- Postman
Follow the video or steps below.
To obtain a list of suspended Okta users using API, a GET request can be made to the Okta Users API with the filter query parameter set to only return suspended users using wither and API clients 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 "SUSPENDED"' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ -H 'Authorization: SSWS {yourAPIkey}' - In the above command, {yourOktaDomain} should be replaced with the Okta domain, and {yourAPIkey} should be replaced with the Okta API token.
- The filter parameter is used to retrieve a filtered list of users, specifically those with a SUSPENDED status.
- The response will contain a JSON-formatted list of suspended users, which can be converted into CSV.
-
Using Postman
-
Prerequisites for Postman:
-
- Postman configured for the org environment as described on 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 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 "SUSPENDED", and if the results surpass 25 users, uncheck the limit parameter and press Send.
-
Save the Response to a file and convert it to CSV.
-
