Docs

getOrganization()

Retrieves a single Organization by the organization ID, if the ID is valid.

function getOrganization: (params: GetOrganizationParams) => Promise<Organization>;
  • Name
    organizationId | slug
    Type
    string
    Description

    The ID of the organization to retrieve, or the slug of the organization to retrieve.

const organizationId = 'org_2ZUtbk2yvnFGItdeze1ivCh3uqh';

const response = await clerkClient.organizations.getOrganization({ organizationId });

console.log(response);
/*
Organization {
  id: 'org_2ZUtbk2yvnFGItdeze1ivCh3uqh',
  name: 'Test',
  slug: 'test',
  imageUrl: 'https://img.clerk.com/eyJ0eXBlIjoiZGVmYXVsdCIsImlpZCI6Imluc18yVjdKRFdyclJwRmZFZTlqQUM2dWpSMG8xSlQiLCJyaWQiOiJvcmdfMlpVdGJrMnl2bkZHSXRkZXplMWl2Q2gzdXFoIiwiaW5pdGlhbHMiOiJUIn0',
  hasImage: false,
  createdBy: 'user_2V7JJKmoA9HqzHhfMqK5cpgLl56',
  createdAt: 1702488558853,
  updatedAt: 1705536009506,
  publicMetadata: {},
  privateMetadata: {},
  maxAllowedMemberships: 3,
  adminDeleteEnabled: true,
  members_count: undefined
}
*/

getOrganization({ slug })

Retrieve an organization by its slug instead of its ID.

const slug = 'my-organization-slug';

const response = await clerkClient.organizations.getOrganization({ slug });

Backend API (BAPI) endpoint

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

Feedback

What did you think of this content?