šŸ“ Sign Up | šŸ” Log In

← Root | ↑ Up

ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā” │ šŸ“„ shadcn/directory/clerk/clerk-docs/reference/javascript/organization │ ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜

╔══════════════════════════════════════════════════════════════════════════════════════════════╗
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘

title: 'Organization object' description: The Organization object holds information about an organization, as well as methods for managing it. sdk: js-frontend

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.

Properties

<Properties> - `id` - `string`

The unique identifier of the related organization.


  • name
  • string

The name of the related organization.


  • slug
  • string | null

The organization slug. If supplied, it must be unique for the instance.


  • imageUrl
  • string

Holds the organization logo or default logo. Compatible with Clerk's Image Optimization.


  • hasImage
  • boolean

A getter boolean to check if the organization has an uploaded image. Returns false if Clerk is displaying an avatar for the organization.


  • membersCount
  • number

The number of members the associated organization contains.


  • pendingInvitationsCount
  • number

The number of pending invitations to users to join the organization.


  • adminDeleteEnabled
  • boolean

A getter boolean to check if the admin of the organization can delete it.


  • maxAllowedMemberships
  • number

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


  • createdAt
  • Date

The date when the organization was created.


  • updatedAt
  • Date

The date when the organization was last updated.


Metadata that can be read from the Frontend API and Backend API{{ target: '_blank' }} and can be set only from the Backend API. </Properties>

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 OrganizationMembership object.

function addMember(params: AddMemberParams): Promise<OrganizationMembership>

AddMemberParams

<Properties> - `userId` - `string`

The ID of the user to be added as a member to the organization.


  • role
  • string

The role that the user will have in the organization. </Properties>

Example

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>

Parameters

<Properties> - `domainName` - `string`

The domain name that will be added to the organization. </Properties>

Example

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>

Example

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>

GetDomainParams

<Properties> - `domainId` - string

The ID of the domain that will be fetched. </Properties>

Example

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

GetDomainsParams

<Properties> - `initialPage?` - `number`

A 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?
  • number

A 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>

Example

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

GetInvitationsParams

<Properties> - `initialPage?` - `number`

A 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?
  • number

A 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>

Example

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

GetMembersParams

<Properties> - `initialPage?` - `number`

A 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?
  • number

A number that indicates the maximum number of results that should be returned for a specific page.


The roles of memberships that will be included in the response. </Properties>

Example

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

GetMembershipRequestParams

<Properties> - `initialPage?` - `number`

A 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?
  • number

A number that indicates the maximum number of results that should be returned for a specific page.


  • status?
  • string

The status of the membership requests that will be included in the response. </Properties>

Example

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

GetRolesParams

<Properties> - `initialPage?` - `number`

A 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?
  • number

A number that indicates the maximum number of results that should be returned for a specific page. </Properties>

Example

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>

InviteMemberParams

<Properties> - `emailAddress` - `string`

The email address to invite.


  • role
  • string

The role of the new member. </Properties>

Example

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[]>

InviteMembersParams

<Properties> - `emailAddresses` - `string[]`

The email addresses to invite.


  • role
  • string

The role of the new members. </Properties>

Example

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>

Parameters

<Properties> - `userId` - `string`

The ID of the user to remove from the organization. </Properties>

Example

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>

SetOrganizationLogoParams

<Properties> - `file` - `File | Blob | null`

An image file or blob which cannot exceed 10MB. Passing null will delete the organization's current logo. </Properties>

Example

await clerk.organization.setLogo({ file })

update()

Updates an organization's attributes. Returns an Organization object.

function update(params: UpdateOrganizationParams): Promise<Organization>

UpdateOrganizationParams

<Properties> - `name` - `string`

The organization name.


  • slug?
  • string | undefined

The organization slug.


  • maxAllowedMemberships?
  • number | undefined

The maximum number of memberships allowed for the organization. Setting this value to 0 removes any limit, allowing an unlimited number of memberships.


Metadata that can be read from both the Frontend API and Backend API{{ target: '_blank' }}, but can be set only from the Backend API.


Metadata that is only visible to your Backend API{{ target: '_blank' }}. </Properties>

Example

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>

UpdateMembershipParams

<Properties> - `userId` - `string`

The ID of the user to update.


  • role
  • string

The role of the new member. </Properties>

Example

await organization.updateMember({ userId: 'user_123', role: 'org:admin' })
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•šā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•

← Root | ↑ Up