<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content
API to Return the Number of Users in a Group
Lifecycle Management
Okta Classic Engine
Okta Identity Engine
Overview

This article discusses whether there is an API that returns the number of users in a group.

Applies To
  • Okta API
  • Groups
Solution

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. 

 

Related References

Loading
API to Return the Number of Users in a Group