Quick Start
Set up a directory, install the SDK, and integrate Directory Sync.
In this guide, we’ll take you from learning about Directory Sync and POC-ing all the way through to building production-ready features fully integrated with the WorkOS Directory Sync API.
This guide will show you how to:
- Create a new directory in the WorkOS Dashboard
- Add Directory Sync to your app and fetch directory resources
- Use events to keep your app in sync with the directory changes
To get the most out of this guide, you’ll need:
- A WorkOS account
- A directory from a directory provider that WorkOS supports
- Directory
- Stores info about an organization’s user management system (i.e. directory provider).
- Directory user
- Represents an organization user that is active in an organization’s directory provider.
- Directory group
- A collection of organization users within a directory, e.g. IT, database admins, HR.
The first step to connecting with a directory is creating an organization in the WorkOS Dashboard. You will then be able to create a new connection to the organization’s directory. Let’s start by creating one for development in your sandbox environment
Get provider-specific instructions by selecting the directory provider you want to test:
Okta
Configure a directory connection to Okta.
Entra ID (Azure AD)
Configure an Entra ID directory connection.
Google Workspace
Configure a Google Workspace directory connection.
All integrations
Choose from dozens of other directory providers.
directory_*.
Let’s integrate the Directory Sync API into your app to enable fetching directory resources programmatically.
WorkOS offers native SDKs in several popular programming languages. Choose a language below to see instructions in your application’s language.
Don't see an SDK you need? Contact us to request an SDK!
Install the SDK using the command below.
| npm install @workos-inc/node |
| yarn add @workos-inc/node |
| gem install workos |
| gem "workos" |
| <dependency> | |
| <groupId>com.workos</groupId> | |
| <artifactId>workos</artifactId> | |
| <version>{version}</version> | |
| </dependency> |
| dependencies { | |
| implementation 'com.workos:workos:VERSION' | |
| } |
To make calls to WorkOS, provide the API key and, in some cases, the client ID. Store these values as managed secrets, such as WORKOS_API_KEY and WORKOS_CLIENT_ID, and pass them to the SDKs either as environment variables or directly in your app’s configuration based on your preferences.
Get the details of an existing directory user.
Example use case: pre-populate user attributes for new user accounts.
List directory users
Get directory users for a given directory or directory group.
Example use case: Build an onboarding experience that allows an admin to select who to invite and create accounts for.
limit, before, and after parameters to paginate through results. See the API Reference for details.
The groups property on the Directory
User object is deprecated. Starting
May 1, 2026, this property returns an empty array by default for newly created
teams. Existing teams currently depending on this property should migrate to
the new access pattern for better throughput performance – the property is
unbounded by user, so users with many group memberships produce large, slow
response payloads. To retrieve a user’s group memberships, use the Fetch user
or group memberships patterns below.
Get directory group
Get the details of an existing directory group.
Example use case: Pre-populate team attributes for new organizations.
List directory groups
Get directory groups for a given directory or directory user.
Example use case: Build an onboarding experience that allows an admin to select which groups of employees to invite and create accounts for.
limit, before, and after parameters to paginate through results. See the API Reference for details.
To fetch the relationship between a specific user and group, scope the list endpoints with a filter parameter. This pattern keeps response payloads bounded by the size of a single user or group, and is the recommended replacement for the deprecated groups field on the directory user object.
To list users that belong to a specific group, pass the group parameter to List directory users:
To list groups a specific user belongs to, pass the user parameter to List directory groups:
Actions performed in a WorkOS environment are represented by events. These can occur as a result of user-related actions, manually via the WorkOS dashboard, or via API calls. To keep your app in sync with the latest directory data, follow the corresponding guides:
- We recommend using our events API to sync data to your application. To learn more about other ways to sync data, see the data syncing guide.
- Learn about the different types of events that you can receive. See event types.
- Understand how directory events work. See the understanding events guide.
- Optionally, stream events to Datadog. See the observability guide.