Skip to main content
Docs

Delete users

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

In the Clerk Dashboard

To delete users in the Clerk Dashboard:

  1. At the top of the Clerk Dashboard, select Users.
  2. 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.

Using the Backend API

You can delete users in your app using Clerk's Backend API.

Use the following tabs to see examples of how to delete users using one of the following:

  • Frontend SDKs, such as Next.js, React, or Remix
  • Express
  • cURL

The following example shows how to delete a user using the JavaScript Backend SDK's deleteUser() method from the users sub-api of the clerkClient instance.

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

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

If you're using Next.js, you must await the instantiation of the clerkClient instance, like so:

const client = await clerkClient()

const response = await client.users.deleteUser(userId)
delete-user.ts
import { clerkClient } from '@clerk/express'

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

  try {
    await clerkClient.users.deleteUser(userId)
    res.status(200).json({ message: 'User deleted' })
  } catch (error) {
    console.log(error)
    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