Sub topic 6
Types of Orgs
This chapter covers the main kinds of Salesforce orgs and how to pick one for a task. It assumes you know what an org is (one tenant's own data, configuration, and users on the shared platform) and the difference between data and metadata. It also assumes you have used a CRM and understand records and tables.
Why there are several org types
An org is a single Salesforce environment. A company rarely works in only one. Changing metadata directly in the org where customers and employees work is risky, so Salesforce offers different org types for different jobs: running the business, testing changes, building and learning, and evaluating the product.
The types are production, sandbox, scratch, Developer Edition, and trial. They differ in four ways:
- Purpose: live work, testing, development, or evaluation.
- Lifespan: permanent, refreshable, disposable, or time-limited.
- Starting contents: real data, copied metadata, or nothing but a definition.
- How you get one: purchase, creation from production, creation from a file, or sign-up.
Production orgs
A production org is the live org that a business uses every day. Real users log in, real customer records live there, and integrations connect to it. It is created when a company buys Salesforce, and its edition is set by that contract.
Production is the source of truth. Other org types are usually derived from it or are used to prepare changes that will later be deployed to it. Because mistakes here affect real work, teams avoid making risky changes directly in production.
You can tell a production org from a sandbox with the IsSandbox field on the Organization object. It is false in production.
Sandboxes
A sandbox is a copy of a production org, created from production. It is used for development, testing, and training without touching live data. Sandboxes are covered in detail in the next chapters, so this section only places them among the other types.
Key facts:
- A sandbox is tied to one production org. You request it from that org's Setup.
- It copies metadata. Depending on the sandbox type, it also copies some or all of the data.
- It can be refreshed, which replaces its contents with a new copy of production.
- The number and types of sandboxes you may have depend on your edition.
- It has its own login URL and usernames. Usernames get the sandbox name appended, for example
[email protected].
Sandbox types range from small, metadata-only copies to full copies of all data. Larger types refresh less often.
Scratch orgs
A scratch org is a disposable org created from a configuration file, not copied from production. You create one with the Salesforce CLI and it expires automatically, after up to 30 days.
Scratch orgs fit source-driven development. The org's shape lives in version control as a definition file. Any developer can create an identical org on demand, deploy code to it, run tests, and delete it.
A minimal definition file looks like this:
{
"orgName": "Tutorial Scratch Org",
"edition": "Developer"
}This command creates a seven-day scratch org from that file:
sf org create scratch --definition-file config/project-scratch-def.json --alias tutorial-scratch --duration-days 7The definition can also request features and settings. The org starts empty of your business data. Scratch orgs are created through a Dev Hub, which is a production or Developer Edition org that has Dev Hub enabled. You must authorize the Dev Hub in the CLI first.
Developer Edition orgs
A Developer Edition org is a free, standalone org for learning and building. You sign up for one and it does not depend on a production org. It includes many platform features, but with lower limits than paid editions, such as less storage and fewer API calls.
Key points:
- It does not expire while you keep using it. Salesforce may deactivate unused ones.
- It is a full, persistent org, unlike a scratch org.
- It is commonly used to explore features, practice, build prototypes, and serve as a Dev Hub.
- Because it is a separate org, anything you build there must be moved to another org through deployment.
Trial orgs
A trial org is a time-limited org for evaluating a product. You sign up for a trial of a particular product, such as Sales Cloud, and get an org with sample data and the features of that product. Trials usually last 30 days, though the length depends on the offer.
When a trial ends, you can convert it to a paid org by purchasing, or it expires. Trials are meant for evaluation, so do not build lasting work in them unless you plan to buy.
Comparing the types
| Org type | Created from | Lifespan | Typical data | Main use |
|---|---|---|---|---|
| Production | Purchase | Permanent | Real business data | Live operations |
| Sandbox | Production | Persistent, refreshable | None to full copy | Testing, development, training |
| Scratch | Definition file via Dev Hub | 1 to 30 days | Empty or loaded by you | Source-driven development, CI |
| Developer Edition | Free sign-up | Persistent | Small sample data | Learning, prototyping |
| Trial | Sign-up for a product | Time-limited | Sample data | Product evaluation |
How the types relate
Notice that sandboxes come from production, while scratch orgs come from a definition file. This is why sandboxes carry your existing configuration and scratch orgs start clean.
Choosing an org for a task
Match the task to the org's strengths:
- Daily business work: production.
- Testing a change against your real configuration and similar data: a sandbox.
- Training users on the current setup: a sandbox with enough data, so a larger sandbox type.
- Building a feature with version control and automated tests: a scratch org.
- Learning, or testing an idea unrelated to any company: Developer Edition.
- Deciding whether to buy a product: a trial.
Common errors
- Treating a sandbox as permanent. A refresh overwrites its contents. Work done only in the sandbox is lost unless it was deployed elsewhere or saved in source control.
- Expecting data in a scratch org. It has metadata from your definition and source, and no business records. Load test data yourself.
- Building lasting work in a trial or a scratch org. Both end. Keep the source in version control.
- Assuming a sandbox matches production exactly. Partial sandboxes copy only some data, and some settings, integrations, and credentials need re-configuring after creation or refresh.
- Mixing up Developer Edition with a scratch org's edition. A scratch org can request the Developer edition in its definition file, but that does not make it a Developer Edition org. The first is disposable. The second is a persistent, standalone sign-up.
- Confusing a sandbox login. Sandboxes use their own login URL. Logging into the production URL with a sandbox username fails.
Verifying an org's type
You can check the type from a query. This SOQL query reads the single Organization record:
SELECT Id, Name, OrganizationType, IsSandbox, InstanceName FROM OrganizationIsSandbox is true for sandboxes. For scratch orgs it is also true, since they are not production. A later chapter covers reading the edition and combining this with the CLI.
The CLI shows which orgs you have authorized:
sf org login web --alias my-org
sf org list
sf org display --target-org my-orgsf org list groups the results, such as scratch orgs and others, so you can see the kind at a glance. sf org display shows the username and instance URL.
Exercise
Your team wants to build a new feature with automated tests, and every developer must start from an identical, clean org. Which org type fits, and what must be set up first?
Show answer
A scratch org. Each developer creates one from the same definition file stored in version control. A Dev Hub (a production or Developer Edition org with Dev Hub enabled) must be enabled and authorized in the Salesforce CLI first.
Exercise
A tester spends a week configuring reports in a sandbox, and then an admin refreshes it. What happens to the reports, and how could this loss be avoided?
Show answer
The refresh replaces the sandbox's contents with a new copy of production, so the reports are lost. To avoid this, deploy the work to another org or save it in source control before the refresh.
Exercise
A company wants to see whether Sales Cloud suits it before buying anything. Which org type should it use, and why not a Developer Edition org?
Show answer
A trial org. It is made for evaluating a specific product and comes with that product's features and sample data. Developer Edition is meant for learning and building on the platform and does not represent a purchased product's feature set.