Sub topic 5
Identifying an Org: Org ID, My Domain, and Instance
This chapter assumes you know what an org is, the difference between data and metadata, and that Salesforce runs as multi-tenant software on shared infrastructure. It covers the three identifiers you meet most often when you work with an org: the Org ID, the My Domain name, and the instance. By the end you should be able to find each one, say what it is for, and avoid the common mistakes that come from mixing them up.
Why one org needs several identifiers
An org is one customer's isolated slice of a multi-tenant platform. Many orgs share the same servers, so Salesforce needs ways to say three different things:
- Which org is this? That is the Org ID.
- What name do people and tools use to reach it? That is the My Domain.
- Which group of servers currently hosts it? That is the instance.
These answer different questions and change at different rates. The Org ID never changes. The My Domain name changes only if an administrator changes it. The instance can change when Salesforce moves an org, for example during a migration.
| Identifier | Answers | Example | Stable? |
|---|---|---|---|
| Org ID | Which org is this? | `00D5g000001AbCdEAK` | Yes, for the life of the org |
| My Domain | What URL name reaches it? | `acme` in `acme.my.salesforce.com` | Changeable by an admin |
| Instance | Which servers host it? | `NA224`, `CS42`, `EU30` | Can change if the org is moved |
The Org ID
The Org ID is the unique identifier of an org. It is a Salesforce record ID for the Organization record, and it always starts with 00D. That prefix is the key prefix for the Organization object. If you see an ID starting with 00D, it identifies an org, not a user, account, or any other record.
Org IDs come in two lengths:
- 15 characters, which is case-sensitive.
- 18 characters, which is case-insensitive. The extra three characters are a checksum of the case pattern in the first 15.
The two forms refer to the same org. Use the 18-character form when you copy IDs into tools that ignore case, such as spreadsheets, because two different 15-character IDs can look identical when case is ignored.
Because the Org ID is unique and permanent, it is the right value to use when you must tell two orgs apart. Support cases, licensing, managed package installs, and integrations that restrict access to specific orgs all rely on it. A sandbox has its own Org ID, different from the production org it was copied from. Refreshing a sandbox does not turn it into the production org, and the sandbox keeps its own Org ID.
You can find the Org ID in Setup by searching for Company Information in Quick Find. The Salesforce.com Organization ID field shows it. You can also query it:
SELECT Id, Name, OrganizationType, IsSandbox, InstanceName FROM OrganizationThe Id column in the result is the Org ID. The Organization object holds exactly one record per org, so the query always returns one row. The other columns come back in the next sections and later chapters.
My Domain
My Domain is a custom subdomain that Salesforce gives your org, so users reach it at a URL that contains your company name instead of a shared server name. If your chosen name is acme, the login and application URLs use acme.my.salesforce.com.
Before My Domain, every org on the same server shared one hostname, such as na224.salesforce.com. The hostname told you which server you were on, and it changed when the org moved. My Domain separates the name people use from the servers behind it.
My Domain gives you several practical benefits:
- A stable URL that does not change when the instance changes.
- A branded login page and the ability to set login policies per org.
- Support for single sign-on, where users sign in through your identity provider.
- A way to tell orgs apart in your browser. Production and sandbox orgs get different hostnames.
Domain formats by org type
The hostname follows a pattern that depends on the kind of org. Treat these as typical patterns and check your own org, because Salesforce has introduced new URL formats over time.
| Org type | Typical hostname pattern |
|---|---|
| Production | `acme.my.salesforce.com` |
| Sandbox | `acme--sandboxname.sandbox.my.salesforce.com` |
| Developer Edition | `acme-dev-ed.develop.my.salesforce.com` |
| Scratch org | `acme-customer-1234.scratch.my.salesforce.com` |
| Trial | `acme-trial.my.salesforce.com` |
Sandbox names add the sandbox name after a double hyphen. This is why a sandbox URL and a production URL for the same company are easy to tell apart, and why you should check the hostname before you change anything.
Related URLs
The same My Domain produces other hostnames for different parts of the product. Lightning pages use a lightning.force.com hostname, and Setup pages use a my.salesforce-setup.com hostname. They all belong to the same org. If you write code or configuration that builds URLs, do not hard-code a hostname. Read it from the org instead, for example with sf org display, shown later.
Changing My Domain
An administrator can change the My Domain name in Setup under My Domain. Changing it changes the URLs for the org. Bookmarks, integrations, single sign-on settings, and any stored hostnames that use the old name need updating. Salesforce can redirect the old URL for a time, but you should not rely on the redirect.
The instance
An instance is a group of servers and databases that hosts many orgs. When Salesforce says an org is "on NA224," it means the org's data and the services that run it live on that instance. The Org ID does not encode the instance, and the My Domain name does not either, so the instance is a separate fact.
Instance names follow patterns:
- Names such as
NA224orEU30indicate a region and a number. - Names that start with
CSfollowed by a number, such asCS42, have traditionally been used for sandboxes. - Hyperforce, Salesforce's architecture on public cloud providers, uses different names that show the cloud region, for example
USA123style names in some listings.
The exact naming varies by period and architecture, so read the instance from the org instead of guessing it from the name.
Why does the instance matter?
- Status checks. Salesforce Trust publishes service status for each instance. You look up your instance to see whether an incident affects you.
- Maintenance and release windows. Major releases roll out instance by instance, so an instance determines when your org gets a release. Sandboxes usually get a preview earlier than production.
- Data location. The instance reflects the region where the data is hosted, which can matter for compliance.
- IP allowlists. Some older network configurations depended on instance IP ranges. This is a reason to prefer My Domain URLs over instance URLs.
An org can change instance. Salesforce moves orgs for capacity, regional, or architecture reasons, and customers can request moves in some cases. After a move the Org ID and My Domain name stay the same. Only the instance value changes.
Rather than draw a diagram with an unsupported label, the relationship is shown below in the supported format.
Finding the identifiers in three ways
You can read all three values from the Setup UI, a query, and the CLI.
Setup UI
- Search Company Information for the Org ID, the instance, and the org type or edition.
- Search My Domain for the current domain name and its status.
The Company Information page lists the Org ID in the Salesforce.com Organization ID field and the instance in the Instance field.
SOQL
The query shown earlier returns the Org ID in Id and the instance in InstanceName. It also returns IsSandbox and OrganizationType, which you will use in the last chapter of this tutorial to confirm type and edition.
Salesforce CLI
The Salesforce CLI (sf) records each org you authorize. These commands authorize an org, list known orgs, and show details for one:
sf org login web --alias my-org
sf org list
sf org display --target-org my-orgsf org login web opens a browser so you can log in and approve access. The --alias flag gives the org a short name that you can use in later commands. sf org list shows each org the CLI knows about. sf org display prints details for one org, including its username, its Org ID, and its instance URL. The instance URL is the My Domain URL when the org has one, which is another reason to prefer it over a hard-coded hostname.
Common mistakes
- Treating the 15-character ID and 18-character ID as different orgs. They are the same org. Compare the first 15 characters, or convert both to 18.
- Assuming a sandbox shares the production Org ID. A sandbox has its own Org ID. Code that checks the Org ID to decide "am I in production?" works as intended only because of this.
- Hard-coding
na224.salesforce.com. Instance hostnames break when an org moves. Use the My Domain URL or read the URL from the org. - Changing My Domain without a plan. Integrations and single sign-on often store the old hostname.
- Reading edition or type from the URL. The hostname hints at the org type, but it is not authoritative. Use the
Organizationrecord for that.
Exercises
Exercise
A teammate says the sandbox refresh turned the sandbox into production because "it now has the same Org ID." Is that possible, and how would you check?
Show answer
No. A sandbox always has its own Org ID, and a refresh does not give it the production ID. Check by running SELECT Id, IsSandbox FROM Organization in both orgs, or by reading the Salesforce.com Organization ID field in Company Information in each. The IDs differ, and IsSandbox is true only in the sandbox.
Exercise
Your org moves from instance NA224 to a different instance. Which of the three identifiers (Org ID, My Domain, instance) change, and what should your integrations use so they keep working?
Show answer
Only the instance changes. The Org ID and My Domain name stay the same. Integrations should use the My Domain URL, not an instance hostname such as na224.salesforce.com.