Create a Scratch Org User

Although scratch orgs were designed to be used by one developer, sometimes you need other users to test with different profiles and permission sets.

Use the org create user command to create a user. Specify the --set-alias flag 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.

1sf org create user --set-alias qa-user --target-org my-scratch
2Successfully created user "1690397809_test-st9thgoyyyq3@example.com" with ID 0058I002inzvQAA for org 00D80000PhAkUAK.
3
4See more details about this user by running "sf org user display -o 1690397809774_test-st9thgoyyyq3@example.com".

Users are associated with a specific scratch org. Specify the scratch org username or alias at the command line with the --target-org flag if it isn’t already set as the default. If you try to create a user for a non-scratch org, the org create user command fails.

You can customize the new user by creating a definition file and specifying it with the --definition-file flag.

1sf org create user --set-alias qa-user --definition-file config/user-def.json

View the list of users associated with a scratch org with the org list users command. The (A) on the left identifies the administrator user that was created when the scratch org was created.

1sf org list users --target-org my-scratch
2=== Users in org 00D80000PhAkUAK
3
4 Default Alias      Username                                    Profile Name         User Id            
5 ─────── ────────── ─────────────────────────────────────────── ──────────────────── ─────────────── 
6 (A)     my-scratch test-st9thgoyyyq3@example.com               System Administrator 0058I002inzvQAA 
7         qa-user    1690397809_test-st9thgoyyyq3@example.com    Standard User        0058I002inzvQAA

Display details about a user with the org display user command.

1sf org display user --target-org qa-user
2Warning: Secrets are now hidden from 'sf org display user' command output. Use the 'sf org auth' commands instead. <truncated for readability>
3
4=== User Description
5
6 key          label                                                                                                            
7 ──────────── ──────────────────────────────────────────────────────────────────────────────────────────────────────────────── 
8 Username     1690397809_test-st9thgoyyyq3@example.com                                                                         
9 Profile Name Standard User                                                                                                    
10 Id           0058I002inzvQAA                                                                                                  
11 Org Id       00D80000PhAkUAK                                                                                                  
12 Access Token [REDACTED] Use 'sf org auth show-access-token' to view   
13 Instance Url https://connect-enterprise-1121-dev-ed.scratch.my.salesforce.com                                                 
14 Login Url    https://connect-enterprise-1121-dev-ed.scratch.my.salesforce.com                                                 
15 Alias        qa-user

Display sensitive information (access token, password, and SFDX Auth URL) about a user with these org auth commands.

  • org auth show-access-token
  • org auth show-sfdx-auth-url
  • org auth show-password