This article discusses whether there is an API that returns the number of users in a group.
- Okta API
- Groups
Yes. The query parameter expand=stats can be added to the GET request, resulting in additional details about the group being returned in the response.
Request examples:
# ALL groups
GET https://{OktaDomainName}.com/api/v1/groups?limit=100&expand=stats
# Groups matching filter criteria
GET https://{OktaDomainName}.com/api/v1/groups?filter=lastMembershipUpdated gt 2017-04-17T23:16:50.000Z &expand=stats
# Specific group based on Group ID (gid)
GET https://{OktaDomainName}.com/api/v1/groups/00gwy337uaRYJVHTHACG?expand=stats
Response example:
[
{
"id": "00gwy337uaRYJVHTHACG",
"lastUpdated": "2017-03-31T23:16:50.000Z",
"lastMembershipUpdated": "2017-04-17T23:16:50.000Z",
"...": "...",
"type": "APP_GROUP",
"...": "...",
"profile": {
"name": "Domain Group 1",
"...": "...",
"externalId": "nYGCoOeiW0uRVHW3MQcB1Q=="
},
"_embedded": {
"stats": {
"usersCount": 301,
"appCount": 0,
"groupPushMappingsCount": 0,
"...": "..."
}
},
"...": "..."
},
{}
]
To display the app-sourced groups in addition to the number of users in a group, add the app option:
ALL groups
GET https://{OktaDomainName}.com/api/v1/groups?limit=100&expand=app,stats
Read the List of all group API for more information.
