I'm struggling to determine the type of environment of authorized orgs using the SalesforceDX auth commands.

Once you've registered an org if you run

sfdx force:org:list --json

The output results in the following information

    "orgId": "00D9XXXXXXXXX",
    "accessToken": "XXXXXX",
    "instanceUrl": "https://XXX.my.salesforce.com",
    "loginUrl": "https://login.salesforce.com",
    "username": "xxx@xxx.com",
    "clientId": "PlatformCLI",
    "connectedStatus": "Connected",
    "lastUsed": "2020-03-10T14:37:24.471Z"

With that, I'm unable to determine if the org is a Developer Org or a real Production Org (since the loginUrl is the same for both).

Any ideas on how to determine it without need to login or query the org directly?


You also can just query for sandbox (which includes Scratch Orgs):

sfdx force:data:soql:query -q "SELECT IsSandbox FROM Organization LIMIT 1" -u [your_alias]

This will return true. When using this in a build script always use --json and process the result - I prefer .jq to parse the JSON

To differentiate the edition use

sfdx force:data:soql:query -q "SELECT OrganizationType FROM Organization LIMIT 1" -u [your_alias]

which returns "Developer Edition" versus your real production edition like "Enterprise Edition"

  • Thank you Christian, I imagine that there's no way to obtain it directly from the org topic then, we're forced to query the org. – jonathanwiesel Mar 10 '20 at 16:29

This answer is relevant with the assumption that your Orgs have a custom domain setup (based on the information as it seems in the question). If not, you will still need an additional step to find that information.

For any Developer Edition Orgs, the subdomain always ends with -dev-ed.

As an example:

"instanceUrl": "https://mydomainname-dev-ed.my.salesforce.com"

This is also mentioned in this trailhead:

The subdomain ends with -dev-ed, which means that the subdomain is a Salesforce Developer Edition

  • But only if they've set up a custom domain... otherwise it's just a plain "naXX" or something. At that point, you need to query Organization or look at Company Information in Setup. – sfdcfox Mar 10 '20 at 16:16
  • That's a good point. I just went ahead assuming this based on the question that the domain is already setup. – Jayant Das Mar 10 '20 at 16:20

The instanceUrl from

sfdx force:org:list --json 

would also refer the org if the domain is set

During Login we can set the org name Example:

Developer Org

sfdx force:auth:web:login -d -a myHubOrg

Production Org

sfdx force:auth:web:login -d -a myProdOrg

The current configuration of the instance can be checked by

sfdx force:config:list


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.