Skip to main content
Docs

Create users

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

In the Clerk Dashboard

To create users in the Clerk Dashboard:

  1. In the top in the Clerk Dashboard, select Users.
  2. Select Create user.
  3. Enter the required user details and select Create.

Using the Backend API

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

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

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

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

route.ts
export async function POST() {
  try {
    const user = await clerkClient.users.createUser({
      emailAddress: ['test@example.com'],
      password: 'password',
    })
    return Response.json({ message: 'User created', user })
  } catch (error) {
    console.log(error)
    return Response.json({ error: 'Error creating 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.createUser()
create-user.ts
import { clerkClient } from '@clerk/express'

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

  try {
    const user = await clerkClient.users.createUser(userData)
    res.status(200).json({ message: 'User created', user })
  } catch (error) {
    console.log(error)
    res.status(500).json({ error: 'Error creating user' })
  }
})
terminal
curl 'https://api.clerk.com/v1/users' -X POST -H 'Authorization:Bearer YOUR_SECRET_KEY' -H 'Content-Type:application/json' -d '{
  "email_address": ["test@example.com"],
  "password": "my-secure-password"
}'

Feedback

What did you think of this content?

Last updated on