Organization Members
These are all methods on the Organization class that allow you to manage the members of an organization.
getMemberships()
function getMemberships(params?: GetMembersParams): Promise<PaginatedResponse<OrganizationMembership>>;
Retrieve the members of the currently active organization.
GetMembersParams
Name | Type | Description |
---|---|---|
initialPage? | number | A number that can be used to skip the first n-1 pages. For example, if initialPage is set to 10, it is will skip the first 9 pages and will fetch the 10th page. |
pageSize? | number | A number that indicates the maximum number of results that should be returned for a specific page. |
role | string | The roles of memberships that will be included in the response. |
GetMembershipsParams
was updated to GetMembersParams
in September, 2023. The limit
and offset
parameters are now deprecated.
Returns
Type | Description |
---|---|
Promise<PaginatedResponse<OrganizationMembership>> | This method returns a Promise which resolves with a PaginatedResponse of OrganizationMembership objects. |
getMembershipRequests()
Retrieve the membership requests of the currently active organization.
function getMembershipRequests: (params?: GetMembershipRequestParams) => Promise<ClerkPaginatedResponse<OrganizationMembershipRequestResource>>;
GetMembershipRequestParams
Name | Type | Description |
---|---|---|
initialPage? | number | A number that can be used to skip the first n-1 pages. For example, if initialPage is set to 10, it is will skip the first 9 pages and will fetch the 10th page. |
pageSize? | number | A number that indicates the maximum number of results that should be returned for a specific page. |
status? | string | The status of the membership requests that will be included in the response. |
addMember()
function addMember(params: AddMemberParams): Promise<OrganizationMembership>;
Adds a user as a member to an organization. A user can only be added to an organization if they are not already members of it and if they already exist in the same instance as the organization.
Please note that only administrators can add members to an organization.
AddMemberParams
Name | Type | Description |
---|---|---|
userId | string | The ID of the user that will be added as a member to the organization. |
role | string | The role that the user will have in the organization. |
Returns
Type | Description |
---|---|
Promise<OrganizationMembership> | This method returns a Promise which resolves with theOrganizationMembership objects. |
updateMember()
function updateMember(params: UpdateMembershipParams): Promise<OrganizationMembership>;
Updates a member based on the userId
. Currently, only a user's role can be updated.
UpdateMembershipParams
Name | Type | Description |
---|---|---|
userId | string | The user identifier. |
role | string | The role of the new member. |
Returns
Type | Description |
---|---|
Promise<OrganizationMembership> | This method returns a Promise which resolves with the updated OrganizationMembership objects. |
removeMember()
function removeMember(userId: string): Promise<OrganizationMembership>;
Removes a member from the organization based on the userId
.
Properties
Name | Type | Description |
---|---|---|
userId | string | The user identifier. |
Returns
Type | Description |
---|---|
Promise<OrganizationMembership> | This method returns a Promise which resolves with the removed OrganizationMembership objects. |