Using the Events API, is there a way to return the most recent event(s) first? Skip to main content
https://support.okta.com/help/answers?id=906f0000000hzpfias&refurl=http%3a%2f%2fsupport.okta.com%2fhelp%2fanswers
How satisfied are you with the Okta Help Center?
Thank you for your feedback!
How satisfied are you with the Okta Help Center?
1
2
3
4
5
Very Dissatisfied
Very satisfied
Enter content less than 200 characters.
Ask Search:
Louis WinterLouis Winter 

Using the Events API, is there a way to return the most recent event(s) first?

Using the Events API, is there a way to return the most recent event(s) first?  I need to retrieve the last sign on event for a user for a specific app.  I am able to filter the events using the application ID, query for just a specific user, and limit the results to just 1 but the results are always the oldest events and I need the newest.  The API doesn't show any way of changing the sort order.
Aaron YeeAaron Yee (Okta, Inc.)

Louis,

The Events API doesn't have a method that returns the most recent event first. However, the Events model contains a "Published" attribute, which is a timestamp of the event, so the date data is there (ISO 8601 format). You can then write code to sort and/or extract the most recent event.

Cheers,
Aaron

Louis WinterLouis Winter
Aaron,

Thanks for the update.  I don't think that will work for what I am wanting to do.  I have a status page for a custom application and I wanted to have the date/time each user last logged into the app.  This date/time could be recent, or never if they have been assigned to it but haven't logged in yet.  I really don't want to pull that much data back for every assigned user every time the status page is refreshed.  We'll just go without the last login date/time for now.

Louis