Docs

Delete users

There are two ways to delete users in Clerk: through the Clerk Dashboard or using the Clerk API.

Delete users in the Clerk Dashboard

To delete users in the Clerk Dashboard:

  1. Navigate to the Clerk Dashboard.
  2. In the navigation sidebar, select Users.
  3. You can either select the user and then in the side navigation menu, select Delete user, or select the menu icon on the right side of the user's row and select Delete user.

Delete users using the Clerk API

To delete users using the Clerk API, you can use the deleteUser() method from the users sub-api of the clerkClient instance.

app/api/delete-user/route.ts
import { clerkClient } from '@clerk/nextjs/server'
import { NextResponse } from 'next/server'

export async function DELETE() {
  const userId = 'user_123'

  try {
    await clerkClient().users.deleteUser(userId)
    return NextResponse.json({ message: 'User deleted' })
  } catch (error) {
    console.log(error)
    return NextResponse.json({ error: 'Error deleting user' })
  }
}

Caution

On January 8, 2025, the Node SDK will no longer be available. Upgrade to the Express SDK.

delete-user.ts
import { clerkClient } from '@clerk/clerk-sdk-node'

app.post('/deleteUser', (req, res) => {
  const userId = req.body.userId

  try {
    await clerkClient.users.deleteUser(userId)
    return res.status(200).json({ message: 'User deleted' })
  } catch (error) {
    console.log(error)
    return res.status(500).json({ error: 'Error deleting user' })
  }
})
terminal
curl 'https://api.clerk.com/v1/users/{user_id}' -X DELETE -H 'Authorization:Bearer YOUR_SECRET_KEY' -H 'Content-Type:application/json'

Feedback

What did you think of this content?

Last updated on