Skip to main content

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.

app/organization/page.tsx
'use client'
import { useOrganization } from '@clerk/nextjs'

export default function Page() {
  const { isLoaded, organization } = useOrganization()

  if (!isLoaded) return <div>Loading...</div>

  return <h1>Welcome to {organization?.name}</h1>
}
  • Name
    adminDeleteEnabled
    Type
    boolean
    Description

    Whether the Organization allows admins to delete users.

  • Name
    createdAt
    Type
    Date
    Description

    The date when the Organization was first created.

  • Name
    hasImage
    Type
    boolean
    Description

    Whether the Organization has an image.

  • Name
    id
    Type
    string
    Description

    The unique identifier for the Organization.

  • Name
    imageUrl
    Type
    string
    Description

    Holds the Organization's logo. Compatible with Clerk's Image Optimization.

  • Name
    maxAllowedMemberships
    Type
    number
    Description

    The maximum number of memberships allowed in the Organization.

  • Name
    membersCount
    Type
    number
    Description

    The number of members in the Organization.

  • Name
    name
    Type
    string
    Description

    The name of the Organization.

  • Name
    pendingInvitationsCount
    Type
    number
    Description

    The number of pending invitations in the Organization.

  • 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.

  • Name
    selfServeSSOEnabled
    Type
    boolean
    Description

    Whether the Organization allows self-serve SSO.

  • Name
    slug
    Type
    null | string
    Description

    The URL-friendly identifier of the Organization. If supplied, it must be unique for the instance.

  • Name
    updatedAt
    Type
    Date
    Description

    The date when the Organization was last updated.

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.

  • Name
    userId
    Type
    string
    Description

    The unique identifier of the user to add as a member.

addPaymentMethod()

Adds a payment method.

Returns a BillingPaymentMethodResource object.

function addPaymentMethod(params: AddPaymentMethodParams): Promise<BillingPaymentMethodResource>
  • Name
    gateway
    Type
    "stripe"
    Description

    The payment gateway to use.

  • Name
    paymentToken
    Type
    string
    Description

    A token representing payment details, usually from a payment form.

createDomain()

Creates a new domain.

Returns an OrganizationDomainResource object.

Warning

You must have Verified domains enabled in your app's settings in the Clerk Dashboard.

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.

Warning

You must have Verified domains enabled in your app's settings in the Clerk Dashboard.

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.

Warning

You must have Verified domains enabled in your app's settings in the Clerk Dashboard.

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.

  • Name
    initialPage?
    Type
    number
    Description

    A number that specifies which page to fetch. For example, if initialPage is set to 10, it will skip the first 9 pages and fetch the 10th page. Defaults to 1.

  • Name
    pageSize?
    Type
    number
    Description

    A number that specifies the maximum number of results to return per page. Defaults to 10.

getInvitations()

Gets the list of invitations.

Returns a ClerkPaginatedResponse of OrganizationInvitationResource objects.

function getInvitations(params?: GetInvitationsParams): Promise<ClerkPaginatedResponse<OrganizationInvitationResource>>
  • Name
    initialPage?
    Type
    number
    Description

    A number that specifies which page to fetch. For example, if initialPage is set to 10, it will skip the first 9 pages and fetch the 10th page. Defaults to 1.

  • Name
    pageSize?
    Type
    number
    Description

    A number that specifies the maximum number of results to return per page. Defaults to 10.

  • 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.

Warning

You must have Verified domains and Automatic suggestion enabled in your app's settings in the Clerk Dashboard.

function getMembershipRequests(params?: GetMembershipRequestParams): Promise<ClerkPaginatedResponse<OrganizationMembershipRequestResource>>
  • Name
    initialPage?
    Type
    number
    Description

    A number that specifies which page to fetch. For example, if initialPage is set to 10, it will skip the first 9 pages and fetch the 10th page. Defaults to 1.

  • Name
    pageSize?
    Type
    number
    Description

    A number that specifies the maximum number of results to return per page. Defaults to 10.

  • 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
    initialPage?
    Type
    number
    Description

    A number that specifies which page to fetch. For example, if initialPage is set to 10, it will skip the first 9 pages and fetch the 10th page. Defaults to 1.

  • Name
    pageSize?
    Type
    number
    Description

    A number that specifies the maximum number of results to return per page. Defaults to 10.

  • 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>>
  • Name
    initialPage?
    Type
    number
    Description

    A number that specifies which page to fetch. For example, if initialPage is set to 10, it will skip the first 9 pages and fetch the 10th page. Defaults to 1.

  • Name
    pageSize?
    Type
    number
    Description

    A number that specifies the maximum number of results to return per page. Defaults to 10.

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>
  • Name
    initialPage?
    Type
    number
    Description

    A number that specifies which page to fetch. For example, if initialPage is set to 10, it will skip the first 9 pages and fetch the 10th page. Defaults to 1.

  • Name
    pageSize?
    Type
    number
    Description

    A number that specifies the maximum number of results to return per page. Defaults to 10.

initializePaymentMethod()

Initializes a payment method.

Returns a BillingInitializedPaymentMethodResource object.

function initializePaymentMethod(params: InitializePaymentMethodParams): Promise<BillingInitializedPaymentMethodResource>
  • Name
    gateway
    Type
    "stripe"
    Description

    The payment gateway to use.

inviteMember()

Creates and sends an invitation to the given email address.

Returns an OrganizationInvitationResource object.

function inviteMember(params: InviteMemberParams): Promise<OrganizationInvitationResource>
  • Name
    emailAddress
    Type
    string
    Description

    The email address of the user to invite.

  • 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
    emailAddresses
    Type
    string[]
    Description

    The email addresses of the users to invite.

  • 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>
  • Name
    rotatingTokenNonce?
    Type
    string
    Description

    A nonce to use for rotating the user's token. Used in native application OAuth flows to allow the native client to update its JWT once despite changes in its rotating token.

removeMember()

Removes a member.

Returns an OrganizationMembershipResource object.

function removeMember(userId: string): Promise<OrganizationMembershipResource>
  • Name
    userId
    Type
    string
    Description

    The unique identifier of the user to remove.

Sets or replaces an Organization's logo.

function setLogo(params: SetOrganizationLogoParams): Promise<OrganizationResource>
  • Name
    file
    Type
    null | string | Blob | File
    Description

    The file to set as the Organization's logo. The file must be an image and its size cannot exceed 10MB.

update()

Updates the current Organization.

function update(params: UpdateOrganizationParams): Promise<OrganizationResource>
  • Name
    name
    Type
    string
    Description

    The name of the Organization.

  • Name
    slug?
    Type
    string
    Description

    The URL-friendly identifier of the Organization. If supplied, it must be unique for the instance.

updateMember()

Updates a given member.

Returns an OrganizationMembershipResource object.

function updateMember(params: UpdateMembershipParams): Promise<OrganizationMembershipResource>
  • Name
    role
    Type
    string
    Description

    The Role that will be assigned to the user.

  • Name
    userId
    Type
    string
    Description

    The unique identifier of the user to update.

Feedback

What did you think of this content?

Last updated on