# Okta API call (LastLogIn)

**URL:** <https://devforum.okta.com/t/okta-api-call-lastlogin/23790>\
**Category:** API\
**Created:** [March 28, 2023, 4:32pm UTC](https://devforum.okta.com/t/okta-api-call-lastlogin/23790 "2023-03-28T16:32:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rdax](https://avatars.discourse-cdn.com/v4/letter/r/f0a364/32.png) [@Rdax](https://devforum.okta.com/u/Rdax)\
**Post date:** [March 28, 2023, 4:32pm UTC](https://devforum.okta.com/t/okta-api-call-lastlogin/23790/1 "2023-03-28T16:32:26Z")

</div>

Hi,  
I’d like to know which Okta API to call to get list of users who last logged in 6 months ago?  
I tried search but it doesnt seem to work as I get the “Invalid search criteria” error in Postman when I try this:  
api/v1/users?search=lastLogin gt “2022-10-28T23:59:59.000Z”  
Can someone help?

---

<div class="post-metadata">

**Author:** ![warren](https://avatars.discourse-cdn.com/v4/letter/w/97f17d/32.png) [@warren](https://devforum.okta.com/u/warren)\
**Post date:** [March 28, 2023, 5:28pm UTC](https://devforum.okta.com/t/okta-api-call-lastlogin/23790/2 "2023-03-28T17:28:08Z")

</div>

That is likely due to their data retention policy.

> Log data older than 90 days isn’t returned, in accordance with Okta’s Data Retention Policy (opens new window). Queries that exceed the retention period succeed, but only those results that have a published timestamp within the window are returned.

> **[System Log | Okta Developer](https://developer.okta.com/docs/reference/api/system-log/#data-retention)**
>
> Secure, scalable, and highly available authentication and user management for any app.

---

<div class="post-metadata">

**Author:** ![Rdax](https://avatars.discourse-cdn.com/v4/letter/r/f0a364/32.png) [@Rdax](https://devforum.okta.com/u/Rdax)\
**Post date:** [March 28, 2023, 6:55pm UTC](https://devforum.okta.com/t/okta-api-call-lastlogin/23790/3 "2023-03-28T18:55:11Z")

</div>

Thanks @warren !  
I just need to get a list of users that havent logged-in in a while so I can process them accordingly.

---

<div class="post-metadata">

**Author:** ![warren](https://avatars.discourse-cdn.com/v4/letter/w/97f17d/32.png) [@warren](https://devforum.okta.com/u/warren)\
**Post date:** [March 28, 2023, 9:36pm UTC](https://devforum.okta.com/t/okta-api-call-lastlogin/23790/4 "2023-03-28T21:36:09Z")

</div>

If you’re an Okta admin, you might find the Okta Usage Report to be helpful as well.

> The Okta Usage report contains data about who has signed in to Okta during a specified time period.  
> The report contains the following fields:
> 
> - User
> - Login
> - Number of Logins
> - User Status
> - Last Login\_ISO8601

> **[Report types | Okta](https://help.okta.com/en-us/Content/Topics/Reports/report-types.htm)**
>
> A list of reports that you can run for your org.

---

<div class="post-metadata">

**Author:** ![Rdax](https://avatars.discourse-cdn.com/v4/letter/r/f0a364/32.png) [@Rdax](https://devforum.okta.com/u/Rdax)\
**Post date:** [March 29, 2023, 12:48pm UTC](https://devforum.okta.com/t/okta-api-call-lastlogin/23790/5 "2023-03-29T12:48:31Z")

</div>

Yes. Thanks for your response.  
I can also get that from the Password Health report as well. But I need a way to automatically deactivate (on a daily basis) those users that haven’t logged in the past 6 months. That’s the reason why I need a API call to get that information.

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [February 13, 2024, 11:14pm UTC](https://devforum.okta.com/t/okta-api-call-lastlogin/23790/6 "2024-02-13T23:14:34Z")

</div>


