Load the active organization
A server route needs organization metadata for the active tenant.
Clerk · Module
Retrieves a Clerk Organization through the backend SDK by ID or slug. An optional flag includes the organization's member count.
Call this backend SDK method through the organizations namespace after initializing Clerk. Supply an organization ID, or use a slug to look up the organization by its human-readable identifier; the promise resolves to the backend Organization object, and an optional flag can request the member count.
function getOrganization(params: GetOrganizationParams): Promise<Organization>| Name | Type | Description |
|---|---|---|
organizationId | string | The ID of the Organization to get. |
includeMembersCount | boolean, optional | Whether to include the number of members in the Organization. |
slug | string, optional | Organization slug used instead of the ID for lookup. |
Promise<Organization>
const organizationId = 'org_123'
const organization = await clerkClient.organizations.getOrganization({ organizationId })
console.log(organization)Initializes Clerk separately, then retrieves the backend Organization identified by its ID.
A server route needs organization metadata for the active tenant.
An application stores a readable organization identifier rather than a Clerk organization ID.
An administrative view displays organization size.
It is an asynchronous backend method with the signature getOrganization(params: GetOrganizationParams): Promise<Organization>. The parameters identify the organization, and the resolved value is the backend Organization object.
Follow-up: How can the lookup avoid an ID? Pass slug in the parameter object to retrieve the organization by its slug.
The required lookup value is organizationId, whose type is string. The method also supports the optional includeMembersCount boolean to request the organization's member count.
Follow-up: What does the boolean control? It controls whether the returned organization includes the number of members.
The method is a wrapper around Clerk's backend API endpoint for retrieving an organization by organization ID. Before using it, initialize the Clerk client helper and then call the organizations method.
Follow-up: What client context is needed in an application? The appropriate Clerk SDK client setup is required, and server-side organization context can provide an active organization's ID.
clerkClientorganizationsOrganizationGetOrganizationParamsAuth