How to get instance name/key via API

Is there a way to get the instance name of a Salesforce organisation (like na41) via the REST API in a reliable way? I’ve looked at existing resources available and they do not seem to expose that. I also considered parsing it out of the instance_url value, but it could vary if the org is using a custom domain.


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

With a little bit of reverse engineering, it seems like we can get the instance key using this REST endpoint:[custom-domain]

As an example, if your Salesforce instance URL is:

You can get the key at:

In JavaScript:

    .then((resp) => resp.json())
    .then(function (body) {
    .catch(function (err) {

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x