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 a production org and a non-production org.
- What metadata is (objects, fields, Apex classes, flows, page layouts) and that changes move between orgs by deployment.
- Basic command-line use. Later chapters use the Salesforce CLI (
sf). - Basic Git concepts: repository, commit, branch.
You do not need to know the sandbox types or scratch org commands yet. Later chapters cover them.
Why the landscape matters
An org is one Salesforce environment with its own data, configuration, users, and limits. Most teams work in several orgs at once. Production is where real users and real business data live. Everything else exists so that you can build and test changes without putting production at risk.
Choosing the wrong non-production org causes real problems. A tiny development sandbox cannot hold the data a performance test needs. A copy of production leaves real customer data in the hands of developers. A long-lived shared org slowly drifts away from what production actually looks like. This chapter gives you a map of the org types so that the later chapters can compare them in detail.
The four kinds of org
Production
Production is the org your business runs on. It holds live data and serves real users. It is the only org where changes have business consequences, so it has the strictest rules:
- Apex code cannot be written directly in the production user interface. Code arrives by deployment.
- Deployments to production run Apex tests. Those tests must meet a minimum code coverage threshold, which is 75% across the org's Apex code.
- Production data is real, so it may be regulated (personal data, payment data, health data).
Treat production as the destination of changes, not the place where you create them.
Sandboxes
A sandbox is a copy of a production org that you create from production. It is a separate org that is isolated from production, so changes in a sandbox do not affect production.
There are four sandbox types: Developer, Developer Pro, Partial Copy, and Full. They differ in how much data they hold and how often you can refresh them. Refreshing a sandbox replaces it with a new copy of production's current metadata (and, depending on the type, data).
Key properties of sandboxes:
- They copy production's metadata, so they match production's configuration at the time of creation or refresh.
- They are created from a production org (or from another sandbox, by cloning).
- They are long-lived. Teams often keep them for weeks or months.
- They are created and refreshed through Setup or the CLI, and the work happens on Salesforce's servers, so it can take minutes to hours.
Scratch orgs
A scratch org is a temporary, disposable org that you create from a definition file. It is not a copy of production. You describe the edition, features, and settings you want, and Salesforce builds a new org to match. You then deploy your project's source into it.
Scratch orgs are created from a Dev Hub. A Dev Hub is an org with the Dev Hub feature enabled. It tracks the scratch orgs you create and enforces allocation limits.
Key properties of scratch orgs:
- They are empty of production data by default. You add test data yourself.
- They expire. The lifespan is from 1 to 30 days, and the default is 7.
- They are quick to create, typically in a few minutes, and can be made on demand by developers or by a CI job.
- Their configuration comes from files in version control, so two scratch orgs built from the same definition and source should match.
Developer Edition
A Developer Edition org is a free, standalone org that you sign up for. It is not connected to your production org. It is not a copy of anything, and it does not expire in the way a scratch org does (though Salesforce may deactivate inactive accounts).
Developer Edition orgs are useful for learning, trying a feature, and building managed packages in some workflows. They are a poor place to develop work for a specific production org, because they have no relationship to that org's configuration or data. Do not confuse a Developer Edition org with a Developer sandbox. The names are similar but the two are different things.
Comparing the four at a glance
| Property | Production | Sandbox | Scratch org | Developer Edition |
|---|---|---|---|---|
| Source of configuration | Itself | Copy of production | Definition file plus your source | Standard Developer Edition setup |
| Real data | Yes | Depends on type | No, unless you load it | No |
| Lifespan | Permanent | Until deleted, refreshable | 1 to 30 days | Long-lived |
| Created from | Salesforce contract | Production org | Dev Hub | Public sign-up |
| Typical use | Run the business | Develop, test, train | Short-lived development and CI | Learning, experiments |
The sandbox row says "Depends on type" because that is the main thing the next chapter covers.
How changes flow between orgs
Production is the end of the line. Changes start in a development environment, move through testing environments, and finally reach production. The following diagram shows one common shape of that flow.
Version control sits in the middle because it is the record of what you changed. In a source-driven workflow, the repository is the source of truth, and orgs are places to run it. Chapter 11 designs a pipeline like this in detail.
Working model: where does the configuration come from?
The most useful question to ask about any org is where its configuration comes from. It decides how you keep orgs consistent.
- Production is the source of its own configuration. Admins and deployments change it.
- Sandboxes inherit configuration from production at copy time, and then drift from it as people make changes in the sandbox or in production.
- Scratch orgs get configuration from your definition file and source. Because they are rebuilt from code, they do not drift. You throw them away instead.
- Developer Edition orgs get configuration from whatever the person who owns them has set up.
This explains the main trade-off. Sandboxes give you high fidelity with production, because they start as a copy. Scratch orgs give you reproducibility, because they start from code. Neither is better for every task. The later chapters on the decision framework cover how to pick.
Setting up your tools
You can check which orgs your CLI knows about with the Salesforce CLI. This command lists the orgs you have authorized, including any sandboxes, scratch orgs, and Dev Hubs:
sf org listTo authorize a production org or Dev Hub, log in through the browser and give the org an alias:
sf org login web --alias prodSandboxes use a different login URL from production. When you log in to a sandbox directly, pass the sandbox login URL:
sf org login web --instance-url https://test.salesforce.com --alias my-sandboxAliases are local names that you choose. They make later commands easier to read, for example --target-org prod.
Common errors and misconceptions
- "A sandbox is a backup of production." It is not. A sandbox is a development and test environment. Refreshing it overwrites its own content. It does not protect production data, and you cannot restore production from it.
- "A scratch org is just a small sandbox." It is a different kind of org. It comes from a definition file, not from production, and it expires.
- "Developer Edition and Developer sandbox are the same." They are not. A Developer sandbox is a copy of your production metadata. A Developer Edition org is an unrelated, standalone org.
- Testing only in a scratch org. A scratch org may not have the data volume, integrations, or unusual configuration that production has. A change that passes in a clean scratch org can still fail against production's real configuration. Plan a later stage in a sandbox that resembles production.
- Developing directly in production. Some configuration changes are made there by admins, but code and complex metadata should arrive by deployment. Direct edits are hard to review and hard to reverse.
What comes next
The next chapter looks at the four sandbox types in detail. After that, the tutorial covers sandbox creation and refresh, then scratch orgs and the Dev Hub. By the end, you will use a decision framework to choose between them for a given task.
Exercise
Your team needs to test a Flow against a realistic copy of production configuration, including a managed package and custom settings that took months to set up. Would you rather start from a scratch org or a sandbox, and why?
Show answer
A sandbox. It starts as a copy of production's metadata, so the installed package and custom settings come with it. A scratch org would need that configuration to be rebuilt from a definition file and source, which is slow and may not match production exactly.
Exercise
A developer says, "Our scratch org drifted from production last week, so we refreshed it." What is wrong with this statement?
Show answer
Scratch orgs are not refreshed and are not copies of production. They are built from a definition file and source, and they expire. The statement describes a sandbox, which can be refreshed and which drifts from production over time.
Exercise
For each org, name where its configuration comes from: production, a sandbox, a scratch org, and a Developer Edition org.
Show answer
Production holds its own configuration. A sandbox inherits it from production at copy time. A scratch org gets it from a definition file plus the source you deploy. A Developer Edition org gets it from whatever its owner configures.