A directory group represents an organizational unit of users in a directory provider.
Get the details of an existing Directory Group.
import { WorkOS } from '@workos-inc/node'; const workos = new WorkOS('sk_example_123456789'); const group = await workos.directorySync.getGroup( 'directory_group_01E64QTDNS0EGJ0FMCVY9BWGZT', );
{ "object": "directory_group", "id": "directory_group_01E1JJS84MFPPQ3G655FHTKX6Z", "idp_id": "02grqrue4294w24", "directory_id": "directory_01ECAZ4NV9QMV47GW873HDCX74", "organization_id": "org_01EZTR6WYX1A0DSE2CYMGXQ24Y", "name": "Developers", "raw_attributes": {}, "created_at": "2026-01-15T12:00:00.000Z", "updated_at": "2026-01-15T12:00:00.000Z" }
| curl "https://api.workos.com/directory_groups/directory_group_01E1JJS84MFPPQ3G655FHTKX6Z" \ | |
| --header "Authorization: Bearer sk_example_123456789" |
| import { WorkOS } from '@workos-inc/node'; | |
| const workos = new WorkOS('sk_example_123456789'); | |
| const group = await workos.directorySync.getGroup( | |
| 'directory_group_01E64QTDNS0EGJ0FMCVY9BWGZT', | |
| ); |
| require "workos" | |
| WorkOS.configure do |config| | |
| config.key = "sk_example_123456789" | |
| end | |
| group = WorkOS::DirectorySync.get_group( | |
| "directory_group_01E64QTDNS0EGJ0FMCVY9BWGZT" | |
| ) |
| from workos import WorkOSClient | |
| workos_client = WorkOSClient( | |
| api_key="sk_example_123456789", client_id="client_123456789" | |
| ) | |
| group = workos_client.directory_sync.get_group( | |
| group_id="directory_group_01E64QTDNS0EGJ0FMCVY9BWGZT" | |
| ) |
| package main | |
| import ( | |
| "context" | |
| "github.com/workos/workos-go/v3/pkg/directorysync" | |
| ) | |
| func main() { | |
| directorysync.SetAPIKey("sk_example_123456789") | |
| group, err := directorysync.GetGroup( | |
| context.Background(), | |
| directorysync.GetGroupOpts{ | |
| Group: "directory_group_01E64QTDNS0EGJ0FMCVY9BWGZT", | |
| }, | |
| ) | |
| } |
| <?php | |
| WorkOS\WorkOS::setApiKey("sk_example_123456789"); | |
| $ds = new WorkOS\DirectorySync(); | |
| $group = $ds->getGroup("directory_group_01E64QTDNS0EGJ0FMCVY9BWGZT"); |
| import com.workos.WorkOS; | |
| import com.workos.directorysync.models.Group; | |
| WorkOS workos = new WorkOS("sk_example_123456789"); | |
| String groupId = "directory_group_01E64QTDNS0EGJ0FMCVY9BWGZT"; | |
| Group directoryGroup = workos.directorySync.getDirectoryGroup(groupId); |
| WorkOS.SetApiKey("sk_example_123456789"); | |
| var directorySyncService = new DirectorySyncService(); | |
| var directoryGroupId = "directory_group_01E64QTDNS0EGJ0FMCVY9BWGZT"; | |
| var directoryGroup = await directorySyncService.GetGroup(directoryGroupId); |
| { | |
| "object": "directory_group", | |
| "id": "directory_group_01E1JJS84MFPPQ3G655FHTKX6Z", | |
| "idp_id": "02grqrue4294w24", | |
| "directory_id": "directory_01ECAZ4NV9QMV47GW873HDCX74", | |
| "organization_id": "org_01EZTR6WYX1A0DSE2CYMGXQ24Y", | |
| "name": "Developers", | |
| "raw_attributes": {}, | |
| "created_at": "2026-01-15T12:00:00.000Z", | |
| "updated_at": "2026-01-15T12:00:00.000Z" | |
| } |
GET/directory_groups /:idParameters Returns Get a list of all of existing directory groups matching the criteria specified.
To fetch the groups a single user belongs to, pass the user query parameter
with the directory user’s ID. This is the recommended replacement for the
groups field on the Directory
User object, which is deprecated
and returns an empty array by default for teams created on or after May 1,
2026. The response is bounded by a single user’s memberships, which gives
better throughput performance than the unbounded groups array. Existing
teams still depending on the legacy groups field should migrate to this
access pattern.
import { WorkOS } from '@workos-inc/node'; const workos = new WorkOS('sk_example_123456789'); const groups = await workos.directorySync.listGroups({ directory: 'directory_01ECAZ4NV9QMV47GW873HDCX74', }); console.log(groups.data);
{ "object": "list", "data": [ { "object": "directory_group", "id": "directory_group_01E1JJS84MFPPQ3G655FHTKX6Z", "idp_id": "02grqrue4294w24", "directory_id": "directory_01ECAZ4NV9QMV47GW873HDCX74", "organization_id": "org_01EZTR6WYX1A0DSE2CYMGXQ24Y", "name": "Developers", "raw_attributes": {}, "created_at": "2026-01-15T12:00:00.000Z", "updated_at": "2026-01-15T12:00:00.000Z" } ], "list_metadata": { "before": "directory_group_01HXYZ123456789ABCDEFGHIJ", "after": "directory_group_01HXYZ987654321KJIHGFEDCBA" } }
| curl "https://api.workos.com/directory_groups" \ | |
| --header "Authorization: Bearer sk_example_123456789" |
| import { WorkOS } from '@workos-inc/node'; | |
| const workos = new WorkOS('sk_example_123456789'); | |
| const groups = await workos.directorySync.listGroups({ | |
| directory: 'directory_01ECAZ4NV9QMV47GW873HDCX74', | |
| }); | |
| console.log(groups.data); |
| require "workos" | |
| WorkOS.configure do |config| | |
| config.key = "sk_example_123456789" | |
| end | |
| groups = WorkOS::DirectorySync.list_groups( | |
| directory: "directory_01ECAZ4NV9QMV47GW873HDCX74" | |
| ) |
| from workos import WorkOSClient | |
| workos_client = WorkOSClient( | |
| api_key="sk_example_123456789", client_id="client_123456789" | |
| ) | |
| groups = workos_client.directory_sync.list_groups( | |
| user_id="directory_user_01E64QS50EAY48S0XJ1AA4WX4D" | |
| ) |
| package main | |
| import ( | |
| "context" | |
| "github.com/workos/workos-go/v3/pkg/directorysync" | |
| ) | |
| func main() { | |
| directorysync.SetAPIKey("sk_example_123456789") | |
| list, err := directorysync.ListGroups( | |
| context.Background(), | |
| directorysync.ListGroupsOpts{ | |
| Directory: "directory_01ECAZ4NV9QMV47GW873HDCX74", | |
| }, | |
| ) | |
| } |
| <?php | |
| WorkOS\WorkOS::setApiKey("sk_example_123456789"); | |
| $ds = new WorkOS\DirectorySync(); | |
| [$before, $after, $groups] = $ds->listGroups(); |
| import com.workos.WorkOS; | |
| import com.workos.directorysync.DirectorySyncApi.ListDirectoryGroupOptions; | |
| import com.workos.directorysync.models.DirectoryGroupList; | |
| WorkOS workos = new WorkOS("sk_example_123456789"); | |
| String directoryId = "directory_01ECAZ4NV9QMV47GW873HDCX74"; | |
| ListDirectoryGroupOptions options = | |
| ListDirectoryGroupOptions.builder().directory(directoryId).build(); | |
| DirectoryGroupList groupList = workos.directorySync.listDirectoryGroups(options); |
| WorkOS.SetApiKey("sk_example_123456789"); | |
| var directorySyncService = new DirectorySyncService(); | |
| var directoryId = "directory_01ECAZ4NV9QMV47GW873HDCX74"; | |
| var options = new ListGroupsOptions { Directory = directoryId }; | |
| var groupList = await directorySyncService.ListGroups(options); |
| { | |
| "object": "list", | |
| "data": [ | |
| { | |
| "object": "directory_group", | |
| "id": "directory_group_01E1JJS84MFPPQ3G655FHTKX6Z", | |
| "idp_id": "02grqrue4294w24", | |
| "directory_id": "directory_01ECAZ4NV9QMV47GW873HDCX74", | |
| "organization_id": "org_01EZTR6WYX1A0DSE2CYMGXQ24Y", | |
| "name": "Developers", | |
| "raw_attributes": {}, | |
| "created_at": "2026-01-15T12:00:00.000Z", | |
| "updated_at": "2026-01-15T12:00:00.000Z" | |
| } | |
| ], | |
| "list_metadata": { | |
| "before": "directory_group_01HXYZ123456789ABCDEFGHIJ", | |
| "after": "directory_group_01HXYZ987654321KJIHGFEDCBA" | |
| } | |
| } |
GET/directory_groupsParameters Returns object