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.api_key = "sk_example_123456789" | |
| end | |
| WorkOS.client.directory_sync.get_group(id: "directory_group_01E1JJS84MFPPQ3G655FHTKX6Z") |
| from workos import WorkOSClient | |
| client = WorkOSClient(api_key="sk_example_123456789", client_id="client_123456789") | |
| client.directory_sync.get_group(id_="directory_group_01E1JJS84MFPPQ3G655FHTKX6Z") |
| package main | |
| import ( | |
| "context" | |
| "github.com/workos/workos-go/v9" | |
| ) | |
| func main() { | |
| client := workos.NewClient("sk_example_123456789") | |
| _, err := client.DirectorySync().GetGroup(context.Background(), "directory_group_01E1JJS84MFPPQ3G655FHTKX6Z") | |
| if err != nil { | |
| panic(err) | |
| } | |
| } |
| <?php | |
| use WorkOS\WorkOS; | |
| $workos = new WorkOS( | |
| apiKey: "sk_example_123456789", | |
| clientId: "client_123456789", | |
| ); | |
| $workos | |
| ->directorySync() | |
| ->getGroup(id: "directory_group_01E1JJS84MFPPQ3G655FHTKX6Z"); |
| import com.workos.WorkOS; | |
| WorkOS workos = new WorkOS("sk_example_123456789"); | |
| workos.directorySync.getGroup("directory_group_01E1JJS84MFPPQ3G655FHTKX6Z"); |
| using WorkOS; | |
| var client = new WorkOSClient(new WorkOSOptions { | |
| ApiKey = "sk_example_123456789", | |
| ClientId = "client_123456789", | |
| }); | |
| await client.DirectorySync.GetGroupAsync("directory_group_01E1JJS84MFPPQ3G655FHTKX6Z"); |
| use workos::Client; | |
| #[tokio::main] | |
| async fn main() -> Result<(), workos::Error> { | |
| let client = Client::builder() | |
| .api_key("sk_example_123456789") | |
| .client_id("client_123456789") | |
| .build(); | |
| let _result = client | |
| .directory_sync() | |
| .get_group("directory_group_01E1JJS84MFPPQ3G655FHTKX6Z") | |
| .await?; | |
| Ok(()) | |
| } |
| { | |
| "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.api_key = "sk_example_123456789" | |
| end | |
| WorkOS.client.directory_sync.list_groups |
| from workos import WorkOSClient | |
| client = WorkOSClient(api_key="sk_example_123456789", client_id="client_123456789") | |
| client.directory_sync.list_groups() |
| package main | |
| import ( | |
| "context" | |
| "github.com/workos/workos-go/v9" | |
| ) | |
| func main() { | |
| client := workos.NewClient("sk_example_123456789") | |
| _, err := client.DirectorySync().ListGroups(context.Background()) | |
| if err != nil { | |
| panic(err) | |
| } | |
| } |
| <?php | |
| use WorkOS\WorkOS; | |
| $workos = new WorkOS( | |
| apiKey: "sk_example_123456789", | |
| clientId: "client_123456789", | |
| ); | |
| $workos->directorySync()->listGroups(); |
| import com.workos.WorkOS; | |
| WorkOS workos = new WorkOS("sk_example_123456789"); | |
| workos.directorySync.listGroups(); |
| using WorkOS; | |
| var client = new WorkOSClient(new WorkOSOptions { | |
| ApiKey = "sk_example_123456789", | |
| ClientId = "client_123456789", | |
| }); | |
| await client.DirectorySync.ListGroupsAsync(); |
| use workos::Client; | |
| #[tokio::main] | |
| async fn main() -> Result<(), workos::Error> { | |
| let client = Client::builder() | |
| .api_key("sk_example_123456789") | |
| .client_id("client_123456789") | |
| .build(); | |
| let _result = client | |
| .directory_sync() | |
| .list_groups() | |
| .await?; | |
| Ok(()) | |
| } |
| { | |
| "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