Skip to main content
The Write Hook, which runs anytime you create or update a user, allows you to do things like:
  • Changing the user’s password
  • Changing the user’s email address
  • Updating the user’s profile
You can also use the Write Hook to automatically set default values for newly-created users. For example, you might want to automatically assign a user to the same group, department, or vendor as the ones to which you’ve been assigned.
Auth0 only supports user creation with Database Connections.

Hook contract

  • ctx: Context object.
    • request.originalUser: Current user’s values where the payload is the new set of fields. Only available when the method is update.
    • payload: Payload object
      • memberships: Array of memberships that were selected in the UI when creating the user.
      • email: Email address of the user.
      • password: Password of the user.
      • connection: Name of the database connection.
      • app_metadata: Data that’s included if a Custom Field being modified is saved in app_metadata.
      • user_metadata: Data that’s included if a Custom Field being modified is saved in user_metadata.
    • userFields: User fields array (if specified in the settings query)
    • method: Either create or update depending on whether this is being called as a result of a create or an update call.
  • callback(error, user): Callback to which you can return an error and the user object that should be sent to the .
For more information about userFields, read Delegated Administration: Settings Query Hook.

Sample use

Kelly manages the Finance department. When she creates users, these users should be assigned as members of the Finance department.

Learn more