Clerk logo

Clerk Docs

Ctrl + K
Go to clerkstage.dev

Organization

The Organization object describes a user created organization structure.

Overview

The Organization object is the model around the organization entity.​

Attributes

NameTypeDescription
idstring

A unique identifier for this organization.

logoUrl string

The full URL for the organization logo.

namestring

The organization name.

publicMetadataobject

Additional information about the organization that can be read through the Frontend API, but written only from the Backend API.

slugstring

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

createdAtDate

Date of the time the organization was created.

updatedAtDate

Date of the last time the user was updated.

Methods

addMember(params)

addMember(params: AddMemberParams) => Promise<OrganizationMembershipResource>

Adds a user as a member to an organization. A user can only be added to an organization if they are not already members of it and if they already exist in the same instance as the organization.

Please note that only administrators can add members to an organization.

Parameters

NameTypeDescription
userIdstring

The id of the user that will be added as a member to the organization.

rolestring

The role that the user will have in the organization. Valid values are admin and basic_member.

Returns

TypeDescription
Promise<OrganizationMembershipResource>

This method returns a Promise which resolves with a OrganizationMembershipResource object.

destroy()

destroy() => Promise<void>

Deletes the organization. Only administrators can delete an organization.

Please note that deleting an organization will also delete all memberships and invitations. This is not reversible.

Returns

TypeDescription
Promise<void>

This method returns a Promise which doesn't resolve to any value.

getMemberships(params)

getMemberships(params?: GetMembershipsParams)=>Promise<OrganizationMembershipResource[]>

Retrieve the members of the selected

Parameters

NameTypeDescription
limit?number

Limit of the results returned.

offset?number

The offset of results to start the retrieval.

Returns

TypeDescription
Promise<OrganizationMembershipResource>

This method returns a Promise which resolves with a list of OrganizationMembershipResource objects.

getPendingInvitations()

getPendingInvitations()=>Promise<OrganizationInvitationResource[]>

Retrieve the members of the selected organization.

Returns

TypeDescription
Promise<OrganizationMembershipResource>

This method returns a Promise which resolves with a list of OrganizationMembershipResource objects.

inviteMember(params)

inviteMember(params: InviteMemberParams) =>Promise<OrganizationInvitationResource>

Creates and sends an invitation to the target email address for becoming a member with the role passed on the function parameters.

Parameters

NameTypeDescription
emailAddressstring

The email address to invite.

roleMembershipRole

The role of the new member.

redirectUrl?string

A URL to redirect the user after accepting the invitation.

Returns

TypeDescription
Promise<OrganizationMembershipResource>

This method returns a Promise which resolves to the OrganizationInvitationResource for the created invitation.

setLogo(params)

setLogo(params: SetOrganizationLogoParams) => Promise<OrganizationResource>

Sets or replaces an organization's logo. Accept the logo as a file or blob. The logo must be an image and its size cannot exceed 10MB.

Parameters

NameTypeDescription
fileFile | Blob | null

An image file which cannot exceed 10MB. Passing `null` will delete the organization's current logo.

Returns

TypeDescription
Promise<OrganizationResource>

This method returns a Promise which resolves to an Organization.

update(params)

update(params: UpdateOrganizationParams) => Promise<OrganizationResource>

Updates an organization's attributes.

Parameters

NameTypeDescription
namestring

The organization name.

Returns

TypeDescription
Promise<OrganizationResource>

This method returns a Promise which resolves to an Organization.

updateMember(params)

updateMember(params: UpdateMembershipParams) =>Promise<OrganizationMembershipResource>

Updates a member based on the userId. For now only role can be changed.

Parameters

NameTypeDescription
roleMembershipRole

The role of the new member.

userIdstring

The user identifier.

Returns

TypeDescription
Promise<OrganizationResource>

This method returns a Promise which resolves to an Organization.

removeMember(params)

removeMember(userId: string) =>Promise<OrganizationMembershipResource>

Removes a member from the organization based on the userId.

Parameters

NameTypeDescription
userIdstring

The user identifier.

Returns

TypeDescription
Promise<OrganizationMembershipResource>

This method returns a Promise which resolves to the removed OrganizationMembershipResource.

Was this helpful?

Clerk © 2023