Newer Version Available

This content describes an older version of this product. View Latest

Scratch Org Users

A scratch org includes one administrator user by default. The admin user is typically adequate for all your testing needs. But sometimes you need other users to test with different profiles and permission sets.

You can create a user by opening the scratch org in your browser and navigating to the Users page in Setup. You can also use the force:user:create CLI command to easily integrate the task into a continuous integration job.

Scratch Org User Limits, Defaults, and Considerations

  • You can create a user only for a specific scratch org. If you try to create a user for a non-scratch org, the command fails. Also specify your Developer Hub, either explicitly or by setting it as your default, so that Salesforce can verify that the scratch org is active.
  • Your scratch org edition determines the number of available user licenses. Your number of licenses determines the number of users you can create. For example, a Developer Edition org includes a maximum of two Salesforce user licenses. Therefore, in addition to the default administrator user, you can create one standard user.
  • The new user’s username must be unique across all Salesforce orgs and in the form of an email address. The username is active only within the bounds of the associated scratch org.
  • You can’t delete a user. The user is deactivated when you delete the scratch org with which the user is associated. Deactivating a user frees up the user license. But you can’t reuse usernames, even if the associated user has been deactivated.
  • The simplest way to create a user is to let the force:user:create command assign default or generated characteristics to the new user. If you want to customize your new user, create a definition file and specify it with the --definitionfile (-f) parameter. In the file, you can include all the User sObject fields and a set of Salesforce DX-specific options, described in User Definition File for Customizing a Scratch Org User. You can also specify these options on the command line.
  • If you do not customize your new user, the force:user:create command creates a user with the following default characteristics.
    • The username is the existing administrator’s username prepended with a timestamp. For example, if the administrator username is test-wvkpnfm5z113@abc.net, the new username is something like 1505759162830_test-wvkpnfm5z113@abc.net.
    • The user’s profile is Standard User.
    • The values of the required fields of the User sObject are the corresponding values of the administrator user. For example, if the administrator’s locale (specifically the LocaleSidKey field of User sObject) is en_US, the new user’s locale is also en_US.