0

This question already has an answer here:

Assume a client app that allows OAUTH login (client flow), such that upon login I can access REST, Tooling, Metadata APIs (etc.) I can get simple org info (id, urls) via an identity call, and I can get the org name by querying the Organization sObject. There are some Tooling API objects (SandboxInfo, SandboxProcess) related to sandbox creation, but the exist only in the prod org. How can I get the sandbox name, assuming I'm logged in and can call any API?

I've seen a number of questions about getting the Sandbox name via Apex (and none with simple answers), but I'm wondering if any of the APIs provide better options. I do not want to rely on hacks such as parsing user names.

Note: As noted above, I am not constrained by running in Apex. I am looking for an API based solution. This is not a duplicate of any of the several 'how do I get sandbox name in Apex' questions on the site.

marked as duplicate by Tushar Sharma, Raul, Pranay Jaiswal, battery.cord, Mohith Shrivastava May 3 at 13:47

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • The last part of the username perhaps? user@org.sandboxname – Boris Bachovski May 3 at 4:41
  • @BorisBachovski User name parsing is an unreliable hack. It will work for users cloned from prod as part of the sandbox creation/refresh, but not necessarily for users created in the sandbox, as the naming convention is not enforced. I'd like an official, supported method for getting the sandbox name via API (if any such thing exists). – Jason Clark May 3 at 5:05
  • @TusharSharma This is not a duplicate, as I am not constrained by running in Apex, as the question you linked. I'm looking for a solution using any available salesforce API. – Jason Clark May 3 at 5:14
  • 1
    @JasonClark There's an InstanceName property on the Organization SOAP API, does that help? – Jayant Das May 3 at 12:22
  • 1
    @JasonClark Oh. I thought it would return the sandbox name. I will see if there's a way to find this out using API – Jayant Das May 3 at 18:24

Browse other questions tagged or ask your own question.