Showing results for 
Show  only  | Search instead for 
Did you mean: 
Community Member

API call to find if user has logged in since a certain date.

Is there an API call that allows you to sort if a user has logged in since a certain date? We are doing some spring cleaning and are trying to sort out current staff from staff that has transitioned. 


0 Kudos
3 Replies
Community Coach
Community Coach

Hi Lee,

There's not really a "logged in since..." API, but certain calls within the Users API can get you the last time the person logged in.  For instance, if you grab all the users in the account and sort by last login:


you get back the last login date as part of the user record for all the users in the account.  I'm not sure what it does with users who have never legged in, though.

You can also get at this information for a specific user (kind of) by looking for the last page view for that user:

https://<server>/api/v1/users/<user id>/page_views?per_page=1

And of course, you can also run the "last access" report under Settings > Reports.

Other folks may have better ways to gather this info, though!



the enrollments API also includes a "last_activity_at" field which can be queried on a course-by-course basis.  Here's an example of adding an indicator to the people page for those that have been active recently:

canvas/branding/javascript/online_users at 6583fb8859f30ae2fa5c48cf910fcb199b8e578d · unsupported/ca... 

Community Champion


The endpoint that Mike provided is good. I just used it this morning to write code that would track logins in mostly real-time (I don't have Live Events enabled, which would probably be easier). It probably would have been easier if I would have found Mike's post first, I stumbled upon it and just wondered what sorting by last_login would do and it added the last_login.

This will show the most recent logins across the institution:

GET /api/v1/accounts/self/users?sort=last_login&order=desc

What I did was extract the most recent date from my database and then fetch the information not following pagination to its completion, but only until I passed that previous date. I then run the code periodically throughout the day to update the last logins.

As I was reading through the source code changes mentioned in the 2020-07-29 deploy notes, I thought I found something new, but it turns out that some people knew about it back in 2018; perhaps it was undocumented.

For individual users, you can use

GET /api/v1/users/:user_id?include[]=last_login

:user_id can be the numeric Canvas user ID or you can use sis_user_id:5678 format.

0 Kudos