Custom Database Script Templates: Create Users

Auth0 provides the following custom database script templates that you can use when implementing user creation functionality.

While Auth0 has populated default templates in the Dashboard script editor, you can use the following links to recover the original code and notes once you've made and saved edits.


When working on your user creation script, keep in mind that:

  • This script will create a new entry in your database.
  • This script executes when a user signs up or when an administrator creates the user via the Dashboard or API.

When the script finishes execution, the Login script runs to verify that the user was created successfully.

The user object

The user object will always contain the following properties:

Property Description
email the user's email
password the password entered by the user (in plain text)
tenant the name of the Auth0 account
client_id the client ID of the application for which the user signed up, or the API key if the user was created through the Dashboard or API
connection the name of the database connection

Finally, if you create and use custom fields during the registration process, these properties are included in the user object as well.

Script execution results

There are three ways a Create Users script can finish:

Result Description
callback(null); A user was successfully created
callback(new ValidationError("user_exists", "my error message")); This user already exists in your database
callback(new Error("my error message")); Something went wrong while trying to reach your database

Sample Scripts

Auth0 provides sample scripts for use with the following languages/technologies:


ASP.NET Membership Provider (MVC3 - Universal Providers)

ASP.NET Membership Provider (MVC4 - Simple Membership)





SQL Server

Windows Azure SQL Database

Request with Basic Auth