Newer Version Available
Create a Scratch Org User
Use the force:user:create command to create a user. Specify the --setalias parameter to assign a simple name to the user that you can reference in later CLI commands. When the command completes, it outputs the new username and user ID.
1sfdx force:user:create --setalias qa-user
2
3Successfully created user "test-b4agup43oxmu@example.com" with ID [0059A000000U0psQAC] for org 00D9A0000000SXKUA2.
4You can see more details about this user by running "sfdx force:user:display -u test-b4agup43oxmu@example.com".Users are associated with a specific scratch org and Developer Hub. Specify the scratch org or Developer Hub username or alias at the command line if they aren’t already set by default in your environment. If you try to create a user for a non-scratch org, the force:user:create command fails.
1sfdx force:user:create --setalias qa-user --targetusername my-scratchorg --targetdevhubusername my-dev-hubThe force:user:create command uses default and generated values for the new user, such as the user’s username, profile, and locale. You can customize the new user by creating a definition file and specifying it with the --definitionfile parameter.
1sfdx force:user:create --setalias qa-user --definitionfile config/user-def.jsonView the list of users associated with a scratch org with the force:user:list command. The (A) on the left identifies the administrator user that was created at the same time that the scratch org was created.
1sfdx force:user:list
2
3
4 ALIAS USERNAME PROFILE NAME USER ID
5─── ────────── ────────────────────────────────── ──────────────────── ──────────────────
6(A) admin-user test-b4agup43oxmu@example.com System Administrator 005xx000001SvBPAA0
7 ci-user wonder@example.com Standard User 005xx000001SvBaAAKDisplay details about a user with the force:user:display command.
1sfdx force:user:display --targetusername ci-user
2
3=== User Description
4KEY VALUE
5─────────────── ───────────────────────────────────────────────────────────
6Access Token <long-string>
7Alias ci-user
8Id 005xx000001SvBaAAK
9Instance Url https://innovation-ability-4888-dev-ed.cs46.my.salesforce.com
10Login Url https://innovation-ability-4888-dev-ed.cs46.my.salesforce.com
11Org Id 00D9A0000000SXKUA2
12Profile Name Standard User
13Username test-b4agup43oxmu@example.com