Docs

getOrganizationList()

Retrieves a list of organizations.

function getOrganizationList: (params: GetOrganizationListParams) => Promise<PaginatedResourceResponse<Organization[]>>;
  • Name
    limit?
    Type
    number
    Description

    The number of results to return. Must be an integer greater than zero and less than 501.

  • Name
    offset?
    Type
    number
    Description

    The number of results to skip.

  • Name
    query?
    Type
    string
    Description

    A search query to filter organizations by.

  • Name
    orderBy?
    Type
    name | updated_at | members_count
    Description

    The field to order by. Prefix with a - to reverse the order. Prefix with a + to list in ascending order.

getOrganizationList() examples

getOrganizationList() with no parameters

In this example, you can see that the returned PaginatedResourceResponse includes data, which is an array of Organization objects, and totalCount, which indicates the total number of organizations in the system.

While the response can return up to 10 data items, for the sake of brevity, only two are shown in this example response.

const response = await clerkClient.organizations.
getOrganizationList();

console.log(response);
/*
{
  data: [
    _Organization {
      id: 'org_2b6TtF4XlxDsKo6t0E0UyywGB72',
      name: 'test-org',
      slug: 'test-org-1705534741',
      imageUrl: 'https://img.clerk.com/eyJ0eXBlIjoiZGVmYXVsdCIsImlpZCI6Imluc18yVjdKRFdyclJwRmZFZTlqQUM2dWpSMG8xSlQiLCJyaWQiOiJvcmdfMmI2VHRGNFhseERzS282dDBFMFV5eXdHQjcyIiwiaW5pdGlhbHMiOiJUIn0',
      hasImage: false,
      createdBy: 'user_2V7JJKmoA9HqzHhfMqK5cpgLl56',
      createdAt: 1705534741971,
      updatedAt: 1705534741971,
      publicMetadata: {},
      privateMetadata: {},
      maxAllowedMemberships: 3,
      adminDeleteEnabled: true,
      members_count: undefined
    },
    _Organization {
      id: 'org_2b6DUVo9M3f0WP8jkIQosTalbxK',
      name: 'Uplevel Digital',
      slug: 'uplevel-digital',
      imageUrl: 'https://img.clerk.com/eyJ0eXBlIjoiZGVmYXVsdCIsImlpZCI6Imluc18yVjdKRFdyclJwRmZFZTlqQUM2dWpSMG8xSlQiLCJyaWQiOiJvcmdfMmI2RFVWbzlNM2YwV1A4amtJUW9zVGFsYnhLIiwiaW5pdGlhbHMiOiJVIn0',
      hasImage: false,
      createdBy: 'user_2b6DRqNmAb01uEvSlgSbDXKajtO',
      createdAt: 1705526650229,
      updatedAt: 1705526650229,
      publicMetadata: {},
      privateMetadata: {},
      maxAllowedMemberships: 3,
      adminDeleteEnabled: true,
      members_count: undefined
    },
    ...
  ],
  totalCount: 25,
}
*/

getOrganizationList({ limit })

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

const { data, totalCount } = await clerkClient.organizations.getOrganizationList({
  // returns the first 10 results
  limit: 10,
});

getOrganizationList({ offset })

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

const { data, totalCount } = await clerkClient.organizations.getOrganizationList({
  // skips the first 10 results
  offset: 10,
});

getOrganizationList({ query })

Retrieves list of organizations that match the query.

// returns organizations that have 'test' in their name
const { data, totalCount } = await clerkClient.organizations.getOrganizationList({ query: 'test' })

Backend API (BAPI) endpoint

This method in the SDK is a wrapper around the BAPI endpoint GET/organizations. See the BAPI reference for more details.

Feedback

What did you think of this content?