revokeInvitation()
Revokes an 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.
function revokeInvitation(invitationId: string): Promise<Invitation>- Name
invitationId- Type
string- Description
The ID of the invitation to revoke.
const invitationId = 'inv_123'
const response = await clerkClient.invitations.revokeInvitation(invitationId)import { clerkClient } from '@clerk/nextjs/server'
import { NextResponse } from 'next/server'
export async function GET() {
try {
const client = await clerkClient()
const invitation = await client.invitations.revokeInvitation({
invitationId: 'invitation_123',
})
return NextResponse.json({ message: 'Invitation revoked' })
} catch (error) {
console.log(error)
return NextResponse.json({ error: 'Error revoking invitation' })
}
}import type { APIRoute } from 'astro'
import { clerkClient } from '@clerk/astro/server'
export const GET: APIRoute = async (context) => {
await clerkClient(context).invitations.revokeInvitation({
invitationId: 'invitation_123',
})
return new Response(JSON.stringify({ success: true }), { status: 200 })
}import { getAuth, clerkClient } from '@clerk/express'
app.post('/revokeInvitation', async (req, res) => {
await clerkClient.invitations.revokeInvitation({
invitationId: 'invitation_123',
})
res.status(200).json({ success: true })
})import { clerkClient } from '@clerk/react-router/server'
import type { Route } from './+types/example'
export async function loader(args: Route.LoaderArgs) {
await clerkClient.invitations.revokeInvitation({
invitationId: 'invitation_123',
})
return { success: true }
}import { json } from '@tanstack/react-start'
import { createFileRoute } from '@tanstack/react-router'
import { clerkClient } from '@clerk/tanstack-react-start/server'
export const ServerRoute = createFileRoute('/api/example')({
server: {
handlers: {
GET: async () => {
await clerkClient().invitations.revokeInvitation({
invitationId: 'invitation_123',
})
return json({ success: true })
},
},
},
})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. Your Secret Key is already injected into the code snippet.
Replace the <invitation_id> with the ID of the invitation you want to revoke and replace YOUR_SECRET_KEY with your Clerk Secret Key. You can find your Secret Key on the API keys page in the Clerk Dashboard.
curl https://api.clerk.com/v1/invitations/<invitation_id>/revoke -X POST -H "Authorization:Bearer YOUR_SECRET_KEY" -H 'Content-Type:application/json'Feedback
Last updated on