I need to get all details of users who haven't performed any activity or login into box.com account for more than 60 days. Is there any API or way to do it?
-
Please add what ever you tried for this. – Amogh Jul 07 '14 at 07:00
-
I am trying to do it through https://api.box.com/2.0/users -H "Authorization: Bearer ACCESS_TOKEN" , but its not returning last activity performed date by user. I am still finding a way to do it. – user25879 Jul 07 '14 at 10:01
2 Answers
Assuming you are an administrator for your Box enterprise, this is possible with the API. However, you have to do it in three steps, and it will require a bit of client-side work.
1. First get a list of all enterprise users as you're already doing now:
curl https://api.box.com/2.0/users
-H "Authorization: Bearer ACCESS_TOKEN"
Depending on the number of users in your enterprise, you will need to repeat this call with an increasing offset
parameter to get all of them. See the docs for more detail.
2. Then get a list of all enterprise events that occurred within the last 60 days:
curl https://api.box.com/2.0/events?stream_type=admin_logs
&created_after=2014-05-07T00:00:00-08:00
-H "Authorization: Bearer ACCESS_TOKEN"
As with the user list, this events list could potentially be quite long. You will likely need to repeat that call multiple times with an increasing stream_position
. Again, the docs explain this in greater detail.
3.
At this point you have a list of enterprise User objects and a list of enterprise Event objects. The Event object has a property created_by
that corresponds to the user that performed the action. A distinct set of created_by.id
values will provide you with the ID of every user that was active in the last N days -- we'll call this list active_user_ids
. You can then filter the User objects for any ID that does not appear in this list. Those are your inactive users. As pseudo code:
foreach user in users
if active_user_ids does not contain user.id
print "user.name has been not been active for at least 60 days"
else
print "user.name has been active within the last 60 days"
Note: Depending on the number and activity of users in your enterprise, the Events list will take a significant amount of time to gather. Consider using the event_type
query string parameter to limit the types of events to just those that you're really interested in.

- 7,955
- 2
- 30
- 40
In step 2 of the above solution - I believe there is a way to retrieve only the LOGIN events. Otherwise the list of events can be pretty large!

- 1