Skip to Content
Clerk logo

Clerk Docs

Ctrl + K
Go to clerkstage.dev

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

NameTypeDescription
initialPage?numberA 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?numberA number that indicates the maximum number of results that should be returned for a specific page.
rolestringThe 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

TypeDescription
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

NameTypeDescription
initialPage?numberA 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?numberA number that indicates the maximum number of results that should be returned for a specific page.
status?stringThe 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

NameTypeDescription
userIdstringThe ID of the user that will be added as a member to the organization.
rolestringThe role that the user will have in the organization.

Returns

TypeDescription
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

NameTypeDescription
userIdstringThe user identifier.
rolestringThe role of the new member.

Returns

TypeDescription
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

NameTypeDescription
userIdstringThe user identifier.

Returns

TypeDescription
Promise<OrganizationMembership>This method returns a Promise which resolves with the removed OrganizationMembership objects.

What did you think of this content?

Clerk © 2024