OrganizationInvitation
The OrganizationInvitation object is the model around an organization invitation.
Properties
- Name
- id
- Type
- string
- Description
- The unique identifier for this organization invitation. 
 
- Name
- emailAddress
- Type
- string
- Description
- The email address the invitation has been sent. 
 
- Name
- organizationId
- Type
- string
- Description
- The organization ID of the organization this invitation is for. 
 
- Name
- publicMetadata
- Type
- OrganizationInvitationPublicMetadata
- Description
- Metadata that can be read from the Frontend API and Backend API and can be set only from the Backend API. 
 
- Name
- role
- Type
- OrganizationCustomRoleKey
- Description
- The role of the current user in the organization. 
 
- Name
- status
- Type
- 'pending' | 'accepted' | 'revoked'
- Description
- The status of the invitation. 
 
- Name
- createdAt
- Type
- Date
- Description
- The date when the invitation was created. 
 
- Name
- updatedAt
- Type
- Date
- Description
- The date when the invitation was last updated. 
 
function revoke(): Promise<OrganizationInvitation>Example
The following example demonstrates how to revoke an organization invitation. It first gets the list of organization invitations using getInvitations() and then revokes the first invitation in the list.
It assumes:
- 
you have followed the quickstart in order to add Clerk to your JavaScript application 
- 
main.js import { Clerk } from '@clerk/clerk-js' const pubKey = import.meta.env.VITE_CLERK_PUBLISHABLE_KEY const clerk = new Clerk(pubKey) await clerk.load() if (clerk.user) { // Check for an active organization if (clerk.organization) { // Get list of organization invitations const { totalCount, data } = await clerk.organization.getInvitations() const invitations = data console.log(`Invitations:`, invitations) if (invitations.length === 0) { console.log('No invitations to revoke.') } // Revoke the first invitation in the list invitations[0] .revoke() .then((res) => console.log(res)) .catch((error) => console.log(error.errors)) } else { // If there is no active organization, // mount Clerk's <OrganizationSwitcher /> // to allow the user to set an organization as active document.getElementById('app').innerHTML = ` <h2>Select an organization to set it as active</h2> <div id="org-switcher"></div> ` const orgSwitcherDiv = document.getElementById('org-switcher') clerk.mountOrganizationSwitcher(orgSwitcherDiv) } } else { document.getElementById('app').innerHTML = ` <div id="sign-in"></div> ` const signInDiv = document.getElementById('sign-in') clerk.mountSignIn(signInDiv) }
Feedback
Last updated on