Organization object
The 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.
Example
The following example uses the useOrganization() hook to access the Organization object.
import { useOrganization } from '@clerk/react'
export default function Page() {
const { isLoaded, organization } = useOrganization()
if (!isLoaded) return <div>Loading...</div>
return <h1>Welcome to {organization?.name}</h1>
}- Name
-
imageUrl - Type
string- Description
Holds the Organization's logo. Compatible with Clerk's Image Optimization.
- Name
-
publicMetadata - Type
- OrganizationPublicMetadata
- Description
Metadata that can be read from both the Frontend API and Backend API, but can be set only from the Backend API. Once the user accepts the invitation and signs up, these metadata will end up in the user's public metadata.
Methods
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 OrganizationMembershipResource object.
function addMember(params: AddMemberParams): Promise<OrganizationMembershipResource>- Name
-
role - Type
string- Description
The Role that will be assigned to the user.
function addPaymentMethod(params: AddPaymentMethodParams): Promise<BillingPaymentMethodResource>function createDomain(domainName: string): Promise<OrganizationDomainResource>- Name
domainName- Type
string- Description
The name of the domain to create.
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>getDomain()
Gets a domain for an Organization based on the given domain ID.
Returns an OrganizationDomainResource object.
function getDomain(domainId: { domainId: string }): Promise<OrganizationDomainResource>- Name
domainId- Type
{ domainId: string; }- Description
The unique identifier of the domain to get.
getDomains()
Gets the list of domains.
Returns a ClerkPaginatedResponse of OrganizationDomainResource objects.
function getDomains(params?: GetDomainsParams): Promise<ClerkPaginatedResponse<OrganizationDomainResource>>- Name
enrollmentMode?- Type
"manual_invitation" | "automatic_invitation" | "automatic_suggestion"- Description
The enrollment mode will decide how new users join an organization.
getInvitations()
Gets the list of invitations.
Returns a ClerkPaginatedResponse of OrganizationInvitationResource objects.
function getInvitations(params?: GetInvitationsParams): Promise<ClerkPaginatedResponse<OrganizationInvitationResource>>- Name
status?- Type
("pending" | "accepted" | "revoked" | "expired")[]- Description
The status of the invitations to get.
getMembershipRequests()
Gets the list of membership requests.
Returns a ClerkPaginatedResponse of OrganizationMembershipRequestResource objects.
function getMembershipRequests(params?: GetMembershipRequestParams): Promise<ClerkPaginatedResponse<OrganizationMembershipRequestResource>>- Name
status?- Type
"pending" | "accepted" | "revoked" | "expired"- Description
The status of the membership requests to get.
getMemberships()
Gets the list of Organization Memberships.
Returns a ClerkPaginatedResponse of OrganizationMembershipResource objects.
function getMemberships(params?: GetMembersParams): Promise<ClerkPaginatedResponse<OrganizationMembershipResource>>- Name
query?- Type
string- Description
The query to filter the users by.
- Name
role?- Type
OrganizationCustomRoleKey[]- Description
The Role to filter the users by.
getPaymentMethods()
Gets a list of payment methods that have been stored.
Returns a ClerkPaginatedResponse of BillingPaymentMethodResource objects.
function getPaymentMethods(params?: GetPaymentMethodsParams): Promise<ClerkPaginatedResponse<BillingPaymentMethodResource>>getRoles()
Gets the list of Roles available.
Returns a ClerkPaginatedResponse of RoleResource objects and a has_role_set_migration status.
When has_role_set_migration is true, updating Organization membership Roles is not allowed. Learn how to build a custom flow for managing member Roles in an Organization.
function getRoles(params?: GetRolesParams): Promise<GetRolesResponse>initializePaymentMethod()
Initializes a payment method.
Returns a BillingInitializedPaymentMethodResource object.
function initializePaymentMethod(params: InitializePaymentMethodParams): Promise<BillingInitializedPaymentMethodResource>inviteMember()
Creates and sends an invitation to the given email address.
Returns an OrganizationInvitationResource object.
function inviteMember(params: InviteMemberParams): Promise<OrganizationInvitationResource>- Name
-
role - Type
string- Description
The Role that will be assigned to the user.
inviteMembers()
Creates and sends invitations to the given email addresses.
Returns an array of OrganizationInvitationResource objects.
function inviteMembers(params: InviteMembersParams): Promise<OrganizationInvitationResource[]>- Name
-
role - Type
string- Description
The Role that will be assigned to the users.
reload()
Reloads the resource, which is useful when you want to access the latest user data after performing a mutation. To make the updated data immediately available, this method forces a session token refresh instead of waiting for the automatic refresh cycle that could temporarily retain stale information. Learn more about forcing a token refresh.
function reload(p?: ClerkResourceReloadParams): Promise<OrganizationResource>function removeMember(userId: string): Promise<OrganizationMembershipResource>- Name
userId- Type
string- Description
The unique identifier of the user to remove.
setLogo()
Sets or replaces an Organization's logo.
function setLogo(params: SetOrganizationLogoParams): Promise<OrganizationResource>update()
Updates the current Organization.
function update(params: UpdateOrganizationParams): Promise<OrganizationResource>function updateMember(params: UpdateMembershipParams): Promise<OrganizationMembershipResource>- Name
-
role - Type
string- Description
The Role that will be assigned to the user.
Feedback
Last updated on