Sub topic 15
Checking Your Own Org's Type and Edition
This chapter shows three ways to find out what kind of org you are using and which edition it runs: the Setup UI, a SOQL query, and the Salesforce CLI. It assumes you know what an org is, the main org types (production, sandbox, scratch, Developer Edition, trial), and what an edition is. It also assumes you can open Setup and have the Salesforce CLI (sf) installed.
Why check
Org type and edition decide what you are allowed to do. A sandbox can be refreshed and broken safely. Production cannot. A Developer Edition org has smaller limits than an Enterprise Edition org. Before you deploy, load data, or file a support case, confirm which org you are in. Names and URLs can mislead you, so check the facts the platform reports.
The three methods answer slightly different questions:
| Method | Best for | What it shows |
|---|---|---|
| Setup UI | Quick human check | Edition, org ID, instance, sandbox status |
| SOQL query | Scripts, Developer Console, anything that can query | Edition, sandbox flag, instance as data |
| Salesforce CLI | Developers with several orgs | Which orgs you are authorized to, usernames, URLs |
Method 1: The Setup UI
- Click the gear icon and choose Setup.
- In Quick Find, type
Company Informationand open it. - Read the Organization Edition, Salesforce.com Organization ID, Instance, and Primary Contact fields.
The Organization Edition field names the edition, for example Developer Edition, Enterprise Edition, or Unlimited Edition. The Instance field names the server group that hosts the org. This page also shows limits such as file storage and data storage, which follow from the edition.
To see whether an org is a sandbox, look at the URL and the page itself. Sandbox orgs usually show a sandbox banner or a sandbox segment in the My Domain URL, such as mycompany--dev.sandbox.my.salesforce.com. Scratch orgs usually have a scratch segment in the domain. Treat the URL as a hint only. The reliable test is the IsSandbox field described next.
If you cannot find Company Information, your user probably lacks the permission to view Setup. Ask an administrator, or use another method below.
Method 2: A SOQL query
SOQL (Salesforce Object Query Language) reads records the way SQL does. Every org has exactly one Organization record that describes the org itself. Run this in the Developer Console Query Editor, in Workbench, or through the CLI:
SELECT Id, Name, OrganizationType, IsSandbox, InstanceName FROM OrganizationThe fields mean the following:
Idis the 15-character org ID (the API returns the 18-character form in some tools). It starts with00D.Nameis the org's name from Company Information.OrganizationTypeis the edition, such asDeveloper Edition,Enterprise Edition, orUnlimited Edition. Despite its name, this field reports the edition, not whether the org is production or sandbox.IsSandboxistruefor a sandbox andfalsefor production, Developer Edition, and trial orgs.InstanceNameis the instance, such asNA45orCS12.
Here is a sample result for a sandbox:
| Id | Name | OrganizationType | IsSandbox | InstanceName |
|---|---|---|---|---|
| 00D5g000001AbCd | Acme | Enterprise Edition | true | CS12 |
Reading this row: the org is Enterprise Edition, it is a sandbox, and it runs on instance CS12. Sandbox instances often have names beginning with CS, but you should rely on IsSandbox, not on the instance name.
You can also run the same query from the CLI:
sf data query --query "SELECT Id, Name, OrganizationType, IsSandbox, InstanceName FROM Organization" --target-org my-orgCommon error: reading `IsSandbox = false` as "production"
A false value means the org is not a sandbox. It can still be a Developer Edition org, a trial org, or a scratch org. Scratch orgs are a special case. They are created by the CLI from a definition file, and they usually report IsSandbox as false. To tell them apart, combine the signals: edition, the scratch segment in the My Domain URL, and whether the CLI lists the org as a scratch org (see below).
Method 3: The Salesforce CLI
The CLI keeps a local list of orgs you have authorized. Use these commands:
sf org login web --alias my-org
sf org list
sf org display --target-org my-orgsf org login web --alias my-orgopens a browser, asks you to log in, and stores an authorization under the aliasmy-org. Use--instance-url https://test.salesforce.comfor a sandbox login if you are not using a My Domain URL.sf org listprints the orgs the CLI knows about. Scratch orgs and other orgs appear in separate groups, and the output marks the default org. Expired scratch orgs are flagged.sf org display --target-org my-orgprints details for one org: the username, org ID, instance URL, API version, and the connection status.
The sf org list grouping is the most direct way to see that an org is a scratch org. The sf org display output includes the instance URL, which you can compare with the patterns from Method 1.
Scratch orgs and expiry
A scratch org is disposable and defined by a configuration file. This minimal definition requests a Developer edition scratch org:
{
"orgName": "Tutorial Scratch Org",
"edition": "Developer"
}Save it as config/project-scratch-def.json, then create the org:
sf org create scratch --definition-file config/project-scratch-def.json --alias tutorial-scratch --duration-days 7The --duration-days 7 option sets the lifetime. After seven days the org is deleted, and sf org list marks it as expired. Once it is created, check it with sf org display --target-org tutorial-scratch and with the SOQL query above. The query should report a Developer edition and IsSandbox as false, which confirms the point from the previous section: the flag alone does not identify a scratch org.
Putting the checks together
Use a short procedure when you start work in an unfamiliar org:
- Run
sf org listto see which orgs you have authorized and which is the default. - Run
sf org display --target-org <alias>to confirm the username and instance URL. - Run the
Organizationquery to read the edition and theIsSandboxflag. - Open Company Information in Setup if you need storage figures or the primary contact.
- Decide what you may do. In a sandbox or scratch org, experiment freely. In production, follow your team's change process.
Edition tells you the feature set and limits. Org type tells you the purpose and the risk. Clouds, the product groupings, are not shown by any of these checks. To see which cloud features you use, look at the licenses and apps the org has, not at the edition.
Common errors
- "INVALID_TYPE: sObject type 'Organization' is not supported." You are querying with a tool that targets a different API or you mistyped the object name. Use
Organizationexactly, and run the query through the Salesforce API. - The CLI shows the wrong org. The default target may be set to a different org. Pass
--target-orgexplicitly. - A sandbox login fails. Sandbox usernames end with the sandbox name, such as
[email protected]. Use the full username. - A scratch org disappears. It expired. Create a new one from the same definition file.
Exercise
A query on Organization returns OrganizationType = "Developer Edition" and IsSandbox = false. Can you conclude the org is production? What else could you check?
Show answer
No. IsSandbox = false means only that the org is not a sandbox. It could be a Developer Edition org, a trial org, or a scratch org. Check the My Domain URL for a scratch segment, run sf org list to see whether the CLI groups it as a scratch org, and look at Company Information in Setup. A Developer Edition org is not a production org in the sense of holding a company's live business data.
Exercise
You run sf org create scratch with --duration-days 7. Name the command you would use six days later to check the org, and explain what a failed result would suggest.
Show answer
Run sf org display --target-org tutorial-scratch, or sf org list to see its status. If the org no longer appears or is marked expired, it has passed its lifetime and has been deleted. Create a new scratch org from the same definition file.