<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content
0D50Z00008G7UplSAFOkta Classic EngineIntegrationsAnswered2024-04-30T09:18:25.000Z2016-02-09T17:23:33.000Z2017-06-16T10:44:08.000Z
Activate a user via Okta API
Hello.

 

In order to activate a disabled user in Okta, the Activate User API call requires the userkey (a key that is 20 alpha-numeric characters long) of the user in Okta. However in order to obtain that key, I normally use the Find User API call where I supply the user's name or email address, and the response back which contains the userkey.  The problem is that when the user is deactivated in Okta, the Find User API call returns empty, so cannot get the userkey.

Thoughts on how to activate a user in Okta via the API if you dont have or cannot get the userkey?

 

Find User API call:

{{url}}/api/v1/users?q=user

 

Activate User API call: 

{{url}}/api/v1/users/{{userId}}/lifecycle/activate?sendEmail=false

  • j5v7c (j5v7c)

    Hello Isaac,

     

    You're correct that the ?q= query will only return activated users.

     

    However, you can still retrieve your deactivated users in multiple ways:

     

    1. By "Deactivated" status: {{url}}/api/v1/users?filter=status eq "DEPROVISIONED"

    2. By login/username: {{url}}/api/v1/users?filter=profile.login eq "[username]"

    3. By email address: {{url}}/api/v1/users?filter=profile.email eq "[email]"

     

    I hope this helps, but please let us know if you need any further help.
    Expand Post
  • Each endpoint (i.e. /users, /apps...) supports different filtering parameters specific to that endpoint.  

    In the documentation you can look under the specific endpoint (i.e "List Users") and there should be a "Filtering" section that documents the supported options. Here is the link for /users...

    http://developer.okta.com/docs/api/resources/users.html#filters(http://developer.okta.com/docs/api/resources/users.html#filters)
    Expand Post
  • svcV.75126 (Customer)

    Isaac,

     

    Outside of the filter and query capabilities I think it is important to note that the standard Get User interface: GET /users/:id 

    will "Fetch a specific user by id, login, or login shortname (as long as it is unambiguous)."

     

    For sequences like you describe (activating a user) i don't generally know the Okta UserID but i always know their Okta Login. I'll fetch the user object using: GET /users/isaac.brock@example.com 

    And then proceed as you describe above to activate the returned user.

     

    -Matt

     

    Expand Post
This question is closed.
Loading
Activate a user via Okta API