Skip to Content
You are viewing a beta version of Clerk Docs
Visit the latest docs
Clerk logo

Clerk Docs

Ctrl + K
Go to clerk.com

getOrganizationMembershipList()

Retrieves a list of memberships for an organization.

function getOrganizationMembershipList: (params: GetOrganizationMembershipListParams) => Promise<PaginatedResourceResponse<OrganizationMembership[]>>;

GetOrganizationMembershipListParams

NameTypeDescription
organizationIdstringThe ID of the organization to retrieve the list of memberships from.
limit?numberThe number of results to return. Must be an integer greater than zero and less than 501.
offset?numberThe number of results to skip.

getOrganizationMembershipList() examples

getOrganizationMembershipList({ organizationId })

In this example, you can see that the returned PaginatedResourceResponse includes data, which is an array of OrganizationMembership objects, and totalCount, which indicates the total number of organization memberships in the system for the specified organization.

const organizationId = 'org_2ZUtbk2yvnFGItdeze1ivCh3uqh'; const response = await clerkClient.organizations.getOrganizationMembershipList({ organizationId }); console.log(response); /* In this example, you can see that data is an array of OrganizationMembership objects, and is populated with two OrganizationMemberships. { data: [ _OrganizationMembership { id: 'orgmem_2b6TUmlDXlo3e9XPq3Wd9EyfIfj', role: 'org:member', publicMetadata: {}, privateMetadata: {}, createdAt: 1705534546701, updatedAt: 1705534546701, organization: [_Organization], publicUserData: [_OrganizationMembershipPublicUserData] }, _OrganizationMembership { id: 'orgmem_2ZUtbeklm2DPSy7jsaLLwf6V8Nq', role: 'org:admin', publicMetadata: {}, privateMetadata: {}, createdAt: 1702488558867, updatedAt: 1702488558867, organization: [_Organization], publicUserData: [_OrganizationMembershipPublicUserData] } ], totalCount: 2 } */

getOrganizationMembershipList({ organizationId, limit })

Retrieves organization membership list that is filtered by the number of results.

const organizationId = 'org_123'; const { data, totalCount } = await clerkClient.organizations.getOrganizationMembershipList({ organizationId, // returns the first 10 memberships limit: 10, });

getOrganizationMembershipList({ organizationId, offset })

Retrieves organizaiton membership list that is filtered by the number of results to skip.

const organizationId = 'org_123'; const { data, totalCount } = await clerkClient.organizations.getOrganizationMembershipList({ organizationId, // skips the first 10 memberships offset: 10, });

Backend API (BAPI) endpoint

This method in the SDK is a wrapper around the BAPI endpoint GET/organizations/{organization_id}/memberships. See the BAPI reference(opens in a new tab) for more details.

Last updated on March 26, 2024

What did you think of this content?

Clerk © 2024