revokeInvitation() - Invitations | Clerk Docs

revokeInvitation()

Revokes the given invitation.

Revoking an invitation makes the invitation email link unusable. However, it doesn't prevent the user from signing up if they follow the sign up flow.

Only active (i.e., non-revoked) invitations can be revoked.

Returns the revoked Invitation.

function revokeInvitation(invitationId: string): Promise<Invitation>

Parameters

Usage

Note: Using clerkClient varies based on the SDK you're using. Refer to the overview for usage details, including guidance on how to access the userId and other properties.

const invitationId = 'inv_123'

const response = await clerkClient.invitations.revokeInvitation(invitationId)

Example

app/api/example/route.ts

import { clerkClient } from '@clerk/nextjs/server'
import { NextResponse } from 'next/server'

export async function POST() {
  // Initialize clerkClient
  const client = await clerkClient()

// Use the `revokeInvitation()` method to revoke the invitation
  const invitation = await client.invitations.revokeInvitation({
    invitationId: 'invitation_123',
  })

return NextResponse.json({ message: 'Invitation revoked' })
}

Backend API (BAPI) endpoint

This method in the SDK is a wrapper around the BAPI endpoint POST/invitations/{invitation_id}/revoke. See the BAPI reference⁠ for more information.

Here's an example of making a request directly to the endpoint using cURL.

Replace the <invitation_id> with the ID of the invitation you want to revoke and replace YOUR_SECRET_KEY with your Clerk Secret Key⁠.

curl https://api.clerk.com/v1/invitations/<invitation_id>/revoke -X POST -H "Authorization:Bearer YOUR_SECRET_KEY" -H 'Content-Type:application/json'