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 quickstartJavaScript Icon in order to add Clerk to your JavaScript application
import { Clerk } from'@clerk/clerk-js'constpubKey=import.meta.env.VITE_CLERK_PUBLISHABLE_KEYconstclerk=newClerk(pubKey)awaitclerk.load()if (clerk.isSignedIn) {// Check for an Active Organizationif (clerk.organization) {// Get list of organization invitationsconst { totalCount,data } =awaitclerk.organization.getInvitations()constinvitations= dataconsole.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 activedocument.getElementById('app').innerHTML =` <h2>Select an organization to set it as active</h2> <div id="org-switcher"></div> `constorgSwitcherDiv=document.getElementById('org-switcher')clerk.mountOrganizationSwitcher(orgSwitcherDiv) }} else {document.getElementById('app').innerHTML =` <div id="sign-in"></div> `constsignInDiv=document.getElementById('sign-in')clerk.mountSignIn(signInDiv)}