diff --git a/.changeset/light-geckos-allow.md b/.changeset/light-geckos-allow.md new file mode 100644 index 0000000000..1255b13f9f --- /dev/null +++ b/.changeset/light-geckos-allow.md @@ -0,0 +1,5 @@ +--- +"@clerk/backend": patch +--- + +Introduce `includeMembersCount` parameter to `getOrganization`, allowing to retrieve an organization with `membersCount`. diff --git a/packages/backend/src/api/endpoints/OrganizationApi.ts b/packages/backend/src/api/endpoints/OrganizationApi.ts index 020eb200f0..b11b4d0657 100644 --- a/packages/backend/src/api/endpoints/OrganizationApi.ts +++ b/packages/backend/src/api/endpoints/OrganizationApi.ts @@ -34,7 +34,9 @@ type CreateParams = { maxAllowedMemberships?: number; } & MetadataParams; -type GetOrganizationParams = { organizationId: string } | { slug: string }; +type GetOrganizationParams = ({ organizationId: string } | { slug: string }) & { + includeMembersCount?: boolean; +}; type UpdateParams = { name?: string; @@ -115,12 +117,16 @@ export class OrganizationAPI extends AbstractAPI { } public async getOrganization(params: GetOrganizationParams) { + const { includeMembersCount } = params; const organizationIdOrSlug = 'organizationId' in params ? params.organizationId : params.slug; this.requireId(organizationIdOrSlug); return this.request({ method: 'GET', path: joinPaths(basePath, organizationIdOrSlug), + queryParams: { + includeMembersCount, + }, }); }