How to Get the Most Active Users
Overview
An example in bash script demonstrating how to fetch the most active users for meetings, calls, inbound emails, and outbound emails using the v11 /mostactiveusers
REST GET
endpoint.
Get Most Active Users
Authenticating
First, you will need to authenticate to the Sugar API. An example is shown below:
curl -X POST -H Cache-Control:no-cache -H "Content-Type: application/json" -d '{
"grant_type":"password",
"client_id":"sugar",
"client_secret":"",
"username":"admin",
"password":"password",
"platform":"custom_api"
}' https://{site_url}/rest/v11/oauth2/token
More information on authenticating can be found in the How to Authenticate and Log Out example and /oauth2/logout endpoint documentation.
Active Users
Next, we can retrieve the most active users using the /mostactiveusers
endpoint.
curl -s -X GET -H OAuth-Token:{access_token} -H Cache-Control:no-cache https://{site_url}/rest/v11/mostactiveusers?days=30
More information on the mostactiveusers API can be found in the /mostactiveusers documentation.
Response
The data received from the server is shown below:
{
"meetings": {
"user_id": "seed_max_id",
"count": "21",
"first_name": "Max",
"last_name": "Jensen"
},
"calls": {
"user_id": "seed_chris_id",
"count": "4",
"first_name": "Chris",
"last_name": "Olliver"
},
"inbound_emails": {
"user_id": "seed_chris_id",
"count": "23",
"first_name": "Chris",
"last_name": "Olliver"
},
"outbound_emails": {
"user_id": "seed_sarah_id",
"count": "20",
"first_name": "Sarah",
"last_name": "Smith"
}
}