WorkOS PHP SDK

OrganizationMembershipService
in package

Table of Contents

Properties

$client  : HttpClient

Methods

__construct()  : mixed
createOrganizationMembership()  : OrganizationMembership
Create an organization membership
deactivateOrganizationMembership()  : OrganizationMembership
Deactivate an organization membership
deleteOrganizationMembership()  : void
Delete an organization membership
getOrganizationMembership()  : UserOrganizationMembership
Get an organization membership
listOrganizationMembershipGroups()  : PaginatedResponse<string|int, Group>
List groups
listOrganizationMemberships()  : PaginatedResponse<string|int, UserOrganizationMembership>
List organization memberships
reactivateOrganizationMembership()  : UserOrganizationMembership
Reactivate an organization membership
updateOrganizationMembership()  : UserOrganizationMembership
Update an organization membership

Properties

Methods

createOrganizationMembership()

Create an organization membership

public createOrganizationMembership(string $userId, string $organizationId[, null|RoleSingle|RoleMultiple $role = null ][, RequestOptions|null $options = null ]) : OrganizationMembership

Creates a new active organization membership for the given organization and user.

Calling this API with an organization and user that match an inactive organization membership will activate the membership with the specified role(s).

Parameters
$userId : string

The ID of the user.

$organizationId : string

The ID of the organization which the user belongs to.

$role : null|RoleSingle|RoleMultiple = null
$options : RequestOptions|null = null
Tags
throws
WorkOSException
Return values
OrganizationMembership

deactivateOrganizationMembership()

Deactivate an organization membership

public deactivateOrganizationMembership(string $id[, RequestOptions|null $options = null ]) : OrganizationMembership

Deactivates an active organization membership. Emits an organization_membership.updated event upon successful deactivation.

  • Deactivating an inactive membership is a no-op and does not emit an event.
  • Deactivating a pending membership returns an error. This membership should be deleted instead.

See the membership management documentation for additional details.

Parameters
$id : string

The unique ID of the organization membership.

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

deleteOrganizationMembership()

Delete an organization membership

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

Permanently deletes an existing organization membership. It cannot be undone.

Parameters
$id : string

The unique ID of the organization membership.

$options : RequestOptions|null = null
Tags
throws
WorkOSException

listOrganizationMembershipGroups()

List groups

public listOrganizationMembershipGroups(string $omId[, string|null $before = null ][, string|null $after = null ][, int|null $limit = null ][, PaginationOrder $order = PaginationOrder::Desc ][, RequestOptions|null $options = null ]) : PaginatedResponse<string|int, Group>

Get a list of groups that an organization membership belongs to.

Parameters
$omId : string

Unique identifier of the Organization Membership.

$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".

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

listOrganizationMemberships()

List organization memberships

public listOrganizationMemberships([string|null $before = null ][, string|null $after = null ][, int|null $limit = null ][, PaginationOrder $order = PaginationOrder::Desc ][, string|null $organizationId = null ][, array<string|int, OrganizationMembershipStatus>|null $statuses = null ][, string|null $userId = null ][, RequestOptions|null $options = null ]) : PaginatedResponse<string|int, UserOrganizationMembership>

Get a list of all organization memberships matching the criteria specified. At least one of user_id or organization_id must be provided. By default only active memberships are returned. Use the statuses parameter to filter by other statuses.

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".

$organizationId : string|null = null

The ID of the organization which the user belongs to.

$statuses : array<string|int, OrganizationMembershipStatus>|null = null

Filter by the status of the organization membership. Array including any of active, inactive, or pending.

$userId : string|null = null

The ID of the user.

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

reactivateOrganizationMembership()

Reactivate an organization membership

public reactivateOrganizationMembership(string $id[, RequestOptions|null $options = null ]) : UserOrganizationMembership

Reactivates an inactive organization membership, retaining the pre-existing role(s). Emits an organization_membership.updated event upon successful reactivation.

  • Reactivating an active membership is a no-op and does not emit an event.
  • Reactivating a pending membership returns an error. The user needs to accept the invitation instead.

See the membership management documentation for additional details.

Parameters
$id : string

The unique ID of the organization membership.

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

updateOrganizationMembership()

Update an organization membership

public updateOrganizationMembership(string $id[, null|RoleSingle|RoleMultiple $role = null ][, RequestOptions|null $options = null ]) : UserOrganizationMembership

Update the details of an existing organization membership.

Parameters
$id : string

The unique ID of the organization membership.

$role : null|RoleSingle|RoleMultiple = null
$options : RequestOptions|null = null
Tags
throws
WorkOSException
Return values
UserOrganizationMembership
On this page

Search results