WorkOS PHP SDK

DirectorySync
in package

Table of Contents

Properties

$client  : HttpClient

Methods

__construct()  : mixed
createDirectorySync()  : DirectorySyncResponse
Sync a Directory
deleteDirectory()  : void
Delete a Directory
getDirectory()  : Directory
Get a Directory
getDirectoryGroup()  : DirectoryGroup
Get a Group for a Directory
getDirectoryUser()  : DirectoryUser
Get a User for a Directory
getGroup()  : DirectoryGroup
Get a Directory Group
getUser()  : DirectoryUserWithGroups
Get a Directory User
listDirectories()  : PaginatedResponse<string|int, Directory>
List Directories
listDirectoryGroups()  : PaginatedResponse<string|int, DirectoryGroup>
List Groups for a Directory
listDirectoryUsers()  : PaginatedResponse<string|int, DirectoryUser>
List Users for a Directory
listGroups()  : PaginatedResponse<string|int, DirectoryGroup>
List Directory Groups
listUsers()  : PaginatedResponse<string|int, DirectoryUserWithGroups>
List Directory Users

Properties

Methods

createDirectorySync()

Sync a Directory

public createDirectorySync(string $id[, RequestOptions|null $options = null ]) : DirectorySyncResponse

Request an asynchronous sync from the directory provider. Currently supports Google Workspace directories in linked or validating state. Manual requests share a five-minute per-directory cooldown across the API, Dashboard, Admin Portal, and MCP. Acceptance means the request was queued, not that the sync has started or completed. A running sync prevents another request from being queued.

Parameters
$id : string

Unique identifier for the Directory.

$options : RequestOptions|null = null
Tags
throws
WorkOSException
Return values
DirectorySyncResponse

deleteDirectory()

Delete a Directory

public deleteDirectory(string $id[, RequestOptions|null $options = null ]) : void

Permanently deletes an existing directory. It cannot be undone.

Parameters
$id : string

Unique identifier for the Directory.

$options : RequestOptions|null = null
Tags
throws
WorkOSException

getDirectoryGroup()

Get a Group for a Directory

public getDirectoryGroup(string $directoryId, string $groupId[, RequestOptions|null $options = null ]) : DirectoryGroup

Get the details of a Directory Group in a Directory.

Parameters
$directoryId : string

Unique identifier of the Directory.

$groupId : string

Unique identifier for the Directory Group.

$options : RequestOptions|null = null
Tags
throws
WorkOSException
Return values
DirectoryGroup

getDirectoryUser()

Get a User for a Directory

public getDirectoryUser(string $directoryId, string $userId[, RequestOptions|null $options = null ]) : DirectoryUser

Get the details of a Directory User in a Directory.

Parameters
$directoryId : string

Unique identifier of the Directory.

$userId : string

Unique identifier for the Directory User.

$options : RequestOptions|null = null
Tags
throws
WorkOSException
Return values
DirectoryUser

listDirectories()

List Directories

public listDirectories([string|null $before = null ][, string|null $after = null ][, int|null $limit = null ][, PaginationOrder $order = PaginationOrder::Desc ][, string|null $organizationId = null ][, string|null $search = null ][, string|null $domain = null ][, RequestOptions|null $options = null ]) : PaginatedResponse<string|int, Directory>

Get a list of all of your existing directories matching the criteria specified.

Parameters
$before : string|null = null

An object ID that defines your place in the list. When the ID is not present, you are at the end of the list.

$after : string|null = null

An object ID that defines your place in the list. When the ID is not present, you are at the end of the list.

$limit : int|null = null

Upper limit on the number of objects to return, between 1 and 100. Defaults to 10.

$order : PaginationOrder = PaginationOrder::Desc

Order the results by the creation time. Defaults to "desc".

$organizationId : string|null = null

Filter Directories by their associated organization.

$search : string|null = null

Searchable text to match against Directory names.

$domain : string|null = null

(deprecated) Filter Directories by their associated domain.

$options : RequestOptions|null = null
Tags
throws
WorkOSException
Return values
PaginatedResponse<string|int, Directory>

listDirectoryGroups()

List Groups for a Directory

public listDirectoryGroups(string $directoryId[, string|null $before = null ][, string|null $after = null ][, int|null $limit = null ][, PaginationOrder $order = PaginationOrder::Desc ][, string|null $user = null ][, RequestOptions|null $options = null ]) : PaginatedResponse<string|int, DirectoryGroup>

Get a list of the Directory Groups in a Directory, optionally filtered to the groups a Directory User belongs to.

Parameters
$directoryId : string

Unique identifier of the Directory.

$before : string|null = null

An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with "obj_123", your subsequent call can include before="obj_123" to fetch a new batch of objects before "obj_123".

$after : string|null = null

An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with "obj_123", your subsequent call can include after="obj_123" to fetch a new batch of objects after "obj_123".

$limit : int|null = null

Upper limit on the number of objects to return, between 1 and 100. Defaults to 10.

$order : PaginationOrder = PaginationOrder::Desc

Order the results by the creation time. Supported values are "asc" (ascending), "desc" (descending), and "normal" (descending with reversed cursor semantics where before fetches older records and after fetches newer records). Defaults to "desc".

$user : string|null = null

Filter Directory Groups to those this Directory User belongs to.

$options : RequestOptions|null = null
Tags
throws
WorkOSException
Return values
PaginatedResponse<string|int, DirectoryGroup>

listDirectoryUsers()

List Users for a Directory

public listDirectoryUsers(string $directoryId[, string|null $before = null ][, string|null $after = null ][, int|null $limit = null ][, PaginationOrder $order = PaginationOrder::Desc ][, string|null $group = null ][, string|null $idpId = null ][, string|null $email = null ][, RequestOptions|null $options = null ]) : PaginatedResponse<string|int, DirectoryUser>

Get a list of the Directory Users in a Directory, optionally filtered to the members of a Directory Group.

Parameters
$directoryId : string

Unique identifier of the Directory.

$before : string|null = null

An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with "obj_123", your subsequent call can include before="obj_123" to fetch a new batch of objects before "obj_123".

$after : string|null = null

An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with "obj_123", your subsequent call can include after="obj_123" to fetch a new batch of objects after "obj_123".

$limit : int|null = null

Upper limit on the number of objects to return, between 1 and 100. Defaults to 10.

$order : PaginationOrder = PaginationOrder::Desc

Order the results by the creation time. Supported values are "asc" (ascending), "desc" (descending), and "normal" (descending with reversed cursor semantics where before fetches older records and after fetches newer records). Defaults to "desc".

$group : string|null = null

Filter Directory Users to the members of this Directory Group.

$idpId : string|null = null

Filter Directory Users by the identity provider's unique identifier (idp_id).

$email : string|null = null

Filter Directory Users by their primary email address.

$options : RequestOptions|null = null
Tags
throws
WorkOSException
Return values
PaginatedResponse<string|int, DirectoryUser>

listGroups()

List Directory Groups

public listGroups([string|null $before = null ][, string|null $after = null ][, int|null $limit = null ][, PaginationOrder $order = PaginationOrder::Desc ][, string|null $directory = null ][, string|null $user = null ][, RequestOptions|null $options = null ]) : PaginatedResponse<string|int, DirectoryGroup>

Get a list of all of existing directory groups matching the criteria specified. Deprecated: use GET /directories/{directoryId}/groups instead.

Parameters
$before : string|null = null

An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with "obj_123", your subsequent call can include before="obj_123" to fetch a new batch of objects before "obj_123".

$after : string|null = null

An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with "obj_123", your subsequent call can include after="obj_123" to fetch a new batch of objects after "obj_123".

$limit : int|null = null

Upper limit on the number of objects to return, between 1 and 100. Defaults to 10.

$order : PaginationOrder = PaginationOrder::Desc

Order the results by the creation time. Supported values are "asc" (ascending), "desc" (descending), and "normal" (descending with reversed cursor semantics where before fetches older records and after fetches newer records). Defaults to "desc".

$directory : string|null = null

Unique identifier of the WorkOS Directory. This value can be obtained from the WorkOS dashboard or from the WorkOS API.

$user : string|null = null

Unique identifier of the WorkOS Directory User. This value can be obtained from the WorkOS API.

$options : RequestOptions|null = null
Tags
throws
WorkOSException
Return values
PaginatedResponse<string|int, DirectoryGroup>

listUsers()

List Directory Users

public listUsers([string|null $before = null ][, string|null $after = null ][, int|null $limit = null ][, PaginationOrder $order = PaginationOrder::Desc ][, string|null $directory = null ][, string|null $group = null ][, string|null $idpId = null ][, string|null $email = null ][, RequestOptions|null $options = null ]) : PaginatedResponse<string|int, DirectoryUserWithGroups>

Get a list of all of existing Directory Users matching the criteria specified. Deprecated: use GET /directories/{directoryId}/users instead.

Parameters
$before : string|null = null

An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with "obj_123", your subsequent call can include before="obj_123" to fetch a new batch of objects before "obj_123".

$after : string|null = null

An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with "obj_123", your subsequent call can include after="obj_123" to fetch a new batch of objects after "obj_123".

$limit : int|null = null

Upper limit on the number of objects to return, between 1 and 100. Defaults to 10.

$order : PaginationOrder = PaginationOrder::Desc

Order the results by the creation time. Supported values are "asc" (ascending), "desc" (descending), and "normal" (descending with reversed cursor semantics where before fetches older records and after fetches newer records). Defaults to "desc".

$directory : string|null = null

Unique identifier of the WorkOS Directory. This value can be obtained from the WorkOS dashboard or from the WorkOS API.

$group : string|null = null

Unique identifier of the WorkOS Directory Group. This value can be obtained from the WorkOS API.

$idpId : string|null = null

Filter Directory Users by the identity provider's unique identifier (idp_id). Requires the directory parameter to also be provided.

$email : string|null = null

Filter Directory Users by their primary email address. Requires the directory parameter to also be provided.

$options : RequestOptions|null = null
Tags
throws
WorkOSException
Return values
PaginatedResponse<string|int, DirectoryUserWithGroups>
On this page

Search results