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 { createClerkClient } from '@clerk/backend'
// Initialize clerkClient
const clerkClient = createClerkClient({
secretKey: process.env.CLERK_SECRET_KEY,
})
export async function POST() {
// Use the `revokeInvitation()` method to revoke the invitation
const invitation = await clerkClient.invitations.revokeInvitation({
invitationId: 'invitation_123',
})
return Response.json({ message: 'Invitation revoked', invitation })
}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' })
}import type { APIRoute } from 'astro'
import { clerkClient } from '@clerk/astro/server'
export const POST: APIRoute = async (context) => {
// Initialize clerkClient
// Use the `revokeInvitation()` method to revoke the invitation
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) => {
// Initialize clerkClient
// Use the `revokeInvitation()` method to revoke the invitation
await clerkClient.invitations.revokeInvitation({
invitationId: 'invitation_123',
})
res.status(200).json({ success: true })
})import type { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify'
import { clerkClient } from '@clerk/fastify'
export const exampleRoutes = (fastify: FastifyInstance) => {
fastify.post('/revokeInvitation', async (req: FastifyRequest, res: FastifyReply) => {
// Initialize clerkClient
// Use the `revokeInvitation()` method to revoke the invitation
await clerkClient.invitations.revokeInvitation({
invitationId: 'invitation_123',
})
res.status(200).json({ success: true })
})
}import { clerkClient } from '@clerk/nuxt/server'
export default defineEventHandler(async (event) => {
// Initialize clerkClient
// Use the `revokeInvitation()` method to revoke the invitation
await clerkClient(event).invitations.revokeInvitation({
invitationId: 'invitation_123',
})
return { success: true }
})import { clerkClient } from '@clerk/react-router/server'
import type { Route } from './+types/example'
import { json, redirect } from 'react-router-dom'
export async function action({ request }: Route.ActionArgs) {
const formData = await request.formData()
const invitationId = formData.get('invitationId')
await clerkClient.invitations.revokeInvitation({
invitationId: invitationId,
})
return json({ 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: {
POST: 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 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 .
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