āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā š shadcn/directory/clerk/clerk-docs/reference/javascript/organization ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā
Organization object'
description: The Organization object holds information about an organization, as well as methods for managing it.
sdk: js-frontendThe Organization object holds information about an organization, as well as methods for managing it.
To use these methods, you must have the Organizations feature enabled in your app's settings in the Clerk Dashboard.
The unique identifier of the related organization.
namestringThe name of the related organization.
slugstring | nullThe organization slug. If supplied, it must be unique for the instance.
imageUrlstringHolds the organization logo or default logo. Compatible with Clerk's Image Optimization.
hasImagebooleanA getter boolean to check if the organization has an uploaded image. Returns false if Clerk is displaying an avatar for the organization.
membersCountnumberThe number of members the associated organization contains.
pendingInvitationsCountnumberThe number of pending invitations to users to join the organization.
adminDeleteEnabledbooleanA getter boolean to check if the admin of the organization can delete it.
maxAllowedMembershipsnumberThe maximum number of memberships allowed for the organization. A value of 0 means there is no limit on the number of members in the organization, allowing an unlimited number of members to join.
createdAtDateThe date when the organization was created.
updatedAtDateThe date when the organization was last updated.
publicMetadataOrganizationPublicMetadataMetadata that can be read from the Frontend API and Backend API{{ target: '_blank' }} and can be set only from the Backend API. </Properties>
addMember()Adds a user as a member to an organization. A user can only be added to an organization if they are not already a member of it and if they already exist in the same instance as the organization. Only administrators can add members to an organization.
Returns an OrganizationMembership object.
function addMember(params: AddMemberParams): Promise<OrganizationMembership>
AddMemberParamsThe ID of the user to be added as a member to the organization.
rolestringThe role that the user will have in the organization. </Properties>
await organization.addMember({ userId: 'user_123', role: 'org:admin' })
createDomain()Creates a new domain for the active organization. Returns an OrganizationDomain object.
[!WARNING] You must have Verified domains enabled in your app's settings in the Clerk Dashboard.
function createDomain(domainName: string): Promise<OrganizationDomainResource>
The domain name that will be added to the organization. </Properties>
await clerk.organization.createDomain('test-domain.com')
destroy()Deletes the organization. Only administrators can delete an organization.
Deleting an organization will also delete all memberships and invitations. This is not reversible.
function destroy(): Promise<void>
await clerk.organization.destroy()
getDomain()Retrieves a domain for an organization based on the given domain ID. Returns an OrganizationDomain object.
[!WARNING] You must have Verified domains enabled in your app's settings in the Clerk Dashboard.
function getDomain(params: GetDomainParams): Promise<OrganizationDomain>
GetDomainParamsThe ID of the domain that will be fetched. </Properties>
await clerk.organization.getDomain({ domainId: 'domain_123' })
getDomains()Retrieves the list of domains for the currently active organization. Returns a ClerkPaginatedResponse of OrganizationDomain objects.
[!WARNING] You must have Verified domains enabled in your app's settings in the Clerk Dashboard.
function getDomains(params?: GetDomainsParams): Promise<ClerkPaginatedResponse<OrganizationDomain>>
GetDomainsParamsA number that can be used to skip the first n-1 pages. For example, if initialPage is set to 10, it is will skip the first 9 pages and will fetch the 10th page.
pageSize?numberA number that indicates the maximum number of results that should be returned for a specific page.
enrollmentMode?'manual_invitation' | 'automatic_invitation' | 'automatic_suggestion'An enrollment mode will change how new users join an organization. </Properties>
await clerk.organization.getDomains()
getInvitations()Retrieves the list of invitations for the currently active organization. Returns a ClerkPaginatedResponse of OrganizationInvitation objects.
function getInvitations(
params?: GetInvitationsParams,
): Promise<ClerkPaginatedResponse<OrganizationInvitation>>
GetInvitationsParamsA number that can be used to skip the first n-1 pages. For example, if initialPage is set to 10, it is will skip the first 9 pages and will fetch the 10th page.
pageSize?numberA number that indicates the maximum number of results that should be returned for a specific page.
status?'pending' | 'accepted' | 'revoked'The status an invitation can have. </Properties>
await clerk.organization.getInvitations()
getMemberships()Retrieves the list of memberships for the currently active organization. Returns a ClerkPaginatedResponse of OrganizationMembership objects.
function getMemberships(
params?: GetMembersParams,
): Promise<ClerkPaginatedResponse<OrganizationMembership>>
GetMembersParamsA number that can be used to skip the first n-1 pages. For example, if initialPage is set to 10, it is will skip the first 9 pages and will fetch the 10th page.
pageSize?numberA number that indicates the maximum number of results that should be returned for a specific page.
role?The roles of memberships that will be included in the response. </Properties>
For an example on how to use getMemberships(), see the custom flow on managing organization roles.
getMembershipRequests()Retrieve the list of membership requests for the currently active organization. Returns a ClerkPaginatedResponse of OrganizationMembershipRequest-request) objects.
[!WARNING] You must have Organizations, and Verified domains and Automatic suggestion enabled in your app's settings in the Clerk Dashboard.
function getMembershipRequests(
params?: GetMembershipRequestParams,
): Promise<ClerkPaginatedResponse<OrganizationMembershipRequestResource>>
GetMembershipRequestParamsA number that can be used to skip the first n-1 pages. For example, if initialPage is set to 10, it is will skip the first 9 pages and will fetch the 10th page.
pageSize?numberA number that indicates the maximum number of results that should be returned for a specific page.
status?stringThe status of the membership requests that will be included in the response. </Properties>
For an example on how to use getMembershipRequests(), see the custom flow guide on managing membership requests.
getRoles()Returns a paginated list of roles in the organization. Returns a ClerkPaginatedResponse of RoleResource objects.
function getRoles(params?: GetRolesParams): Promise<ClerkPaginatedResponse<RoleResource>>
GetRolesParamsA number that can be used to skip the first n-1 pages. For example, if initialPage is set to 10, it is will skip the first 9 pages and will fetch the 10th page.
pageSize?numberA number that indicates the maximum number of results that should be returned for a specific page. </Properties>
await clerk.organization.getRoles()
inviteMember()Creates and sends an invitation to the target email address for becoming a member with the role passed on the function parameters. Returns an OrganizationInvitation object.
function inviteMember(params: InviteMemberParams): Promise<OrganizationInvitation>
InviteMemberParamsThe email address to invite.
rolestringThe role of the new member. </Properties>
await clerk.organization.inviteMember({ emailAddress: 'test@test.com', role: 'org:member' })
inviteMembers()Creates and sends an invitation to the target email addresses for becoming a member with the role passed in the parameters. Returns an array of OrganizationInvitation objects.
function inviteMembers(params: InviteMembersParams): Promise<OrganizationInvitation[]>
InviteMembersParamsThe email addresses to invite.
rolestringThe role of the new members. </Properties>
await clerk.organization.inviteMembers({
emailAddresses: ['test@test.com', 'test2@test.com'],
role: 'org:member',
})
removeMember()Removes a member from the organization based on the userId. Returns an OrganizationMembership object.
function removeMember(userId: string): Promise<OrganizationMembership>
The ID of the user to remove from the organization. </Properties>
await organization.removeMember('user_123')
setLogo()Sets or replaces an organization's logo. The logo must be an image and its size cannot exceed 10MB. Returns an Organization object.
function setLogo(params: SetOrganizationLogoParams): Promise<Organization>
SetOrganizationLogoParamsAn image file or blob which cannot exceed 10MB. Passing null will delete the organization's current logo.
</Properties>
await clerk.organization.setLogo({ file })
update()Updates an organization's attributes. Returns an Organization object.
function update(params: UpdateOrganizationParams): Promise<Organization>
UpdateOrganizationParamsThe organization name.
slug?string | undefinedThe organization slug.
maxAllowedMemberships?number | undefinedThe maximum number of memberships allowed for the organization. Setting this value to 0 removes any limit, allowing an unlimited number of memberships.
publicMetadata?OrganizationPublicMetadataMetadata that can be read from both the Frontend API and Backend API{{ target: '_blank' }}, but can be set only from the Backend API.
privateMetadata?OrganizationPrivateMetadataMetadata that is only visible to your Backend API{{ target: '_blank' }}. </Properties>
await clerk.organization.update({ name: 'New Name' })
updateMember()Updates a member. Currently, only a user's role can be updated. Returns an OrganizationMembership object.
function updateMember(params: UpdateMembershipParams): Promise<OrganizationMembership>
UpdateMembershipParamsThe ID of the user to update.
rolestringThe role of the new member. </Properties>
await organization.updateMember({ userId: 'user_123', role: 'org:admin' })
ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā