Newer Version Available
Create Scratch Orgs
Before you create a scratch org:
- Set up your Salesforce DX project
- Authorize the Dev Hub org
- Create the scratch org definition file
You can create scratch orgs for different functions, such as for feature development, for development of packages that contain a namespace, or for user acceptance testing.
Indicate the path to the scratch definition file relative to your current directory. For sample repos and new projects, this file is located in the config directory.
Ways to Create Scratch Orgs
Specify scratch org definition values on the command line using key=value pairs.
Create a scratch org for user acceptance testing or to test installations of packages. In this case, you don’t want to create a scratch org with a namespace. You can use this command to override the namespace value in the scratch org definition file.
Specify the scratch org’s duration, which indicates when the scratch org expires (in 1-30 days). The default duration is 7 days.
Specify the Salesforce release for the scratch org. During the Salesforce release transition, you can specify the release (preview or previous) when creating a scratch org. See Select the Salesforce Release for a Scratch Org.
If Scratch Org Creation Is Successful
Stdout displays two important pieces of information: the org ID and the username.
Troubleshooting Tips
If the create command times out before the scratch org is created (the default wait time is 6 minutes), you see an error. Issue this command to see if it returns the scratch org ID, which confirms the existence of the scratch org:
This example assumes that your name is Jane Doe, and you created an alias for your Dev Hub org called DevHub:
If that doesn’t work, create another scratch org and increase the timeout value using the --wait parameter. Don’t forget to delete the malfunctioning scratch org.