Sub topic 1
The org landscape: production, sandboxes, scratch orgs, and Developer Edition
Prerequisites
This chapter assumes you already know the following:
- Basic Salesforce administration, including the difference between production and non-production orgs.
- What metadata is and how changes are deployed between orgs.
- Basic command-line use.
- Basic Git and version control concepts.
What an org is
An org is one Salesforce environment. It has its own data, users, configuration, and code. Nothing is shared between orgs unless you move it yourself, by deploying metadata or loading data.
A Salesforce team usually works with several orgs at once. Each one has a different job. Choosing the wrong one causes problems such as testing against unrealistic data, losing work when an org expires, or editing live configuration by accident. This chapter maps the main org types. Later chapters cover each in detail.
The four org types
Production
Production is the org where real users work with real customer data. Changes here affect the business immediately. Treat it as the destination for finished work, not as a place to experiment.
Sandboxes
A sandbox is a copy of a production org. It is created from production and lives in a separate environment. Four types exist: Developer, Developer Pro, Partial Copy, and Full. They differ in how much data they hold and how often you can refresh them. Sandboxes are linked to the production org they came from.
Because a sandbox starts as a copy of production, it carries production's metadata and configuration. This makes it a good place to test how a change behaves in a setup like the real one.
Scratch orgs
A scratch org is a temporary org built from a definition file. You create it from a Dev Hub, which is a production or Developer Edition org that has the Dev Hub feature enabled. A scratch org is not a copy of anything. It starts nearly empty and gets its shape from the definition file and from the source you deploy to it. It expires automatically, after 7 days by default.
Scratch orgs fit source-driven development, where your version control repository, not an org, is the source of truth.
Developer Edition
A Developer Edition org is a free, standalone org for learning and experiments. It is not connected to your production org. It has no copy of your data or configuration and no refresh option. You can use one as a Dev Hub for personal projects.
Comparing them
| Org type | Created from | Starts with | Lifespan |
|---|---|---|---|
| Production | Purchased edition | Your live data and setup | Permanent |
| Sandbox | A production org | A copy of production metadata, plus data depending on type | Persistent, can be refreshed |
| Scratch org | A Dev Hub and a definition file | Almost nothing | Temporary, 7 days by default |
| Developer Edition | Free signup | A blank org with sample data | Persistent, independent |
How they relate
The diagram shows where each org type comes from and where work flows.
Two points are worth noting. First, sandboxes flow from production, while scratch orgs flow from a definition file in your repository. Second, Developer Edition sits outside the main path. It only joins in when you use it as a Dev Hub.
A first look at the commands
You create each org type differently. The Salesforce CLI handles both sandboxes and scratch orgs. These two commands show the contrast. You will run them properly in later chapters.
sf org create sandbox --definition-file config/dev-sandbox-def.json --alias dev1 --target-org prod
sf org create scratch --definition-file config/project-scratch-def.json --alias my-scratch --duration-days 7The sandbox command names a production org as its source with --target-org. The scratch command uses the default Dev Hub, so it does not name a source org.
Common mistakes
- Treating a scratch org as permanent. It expires, so unpushed work is lost.
- Expecting a Developer Edition org to match production. It does not.
- Assuming every sandbox holds production data. Only some types do.
Exercise
A teammate wants to test a new feature against a setup that mirrors production configuration, and also wants a throwaway org for each Git branch. Which org type suits each need, and why?
Show answer
A sandbox suits the production-like test, because it is created as a copy of production and carries its metadata and configuration. A scratch org suits the per-branch work, because it is created quickly from a definition file in the repository, starts clean, and expires automatically.