0

I'm writing an application that works with salesforce.

Is it safe to consider an instance URL globally unique per instance/organization?

(Example: https://na136.salesforce.com/)

For example each user should connect their salesforce instance to my application and to differentiate users I need something unique to identify them, this would be instance URL?

rosghub
  • 217
  • 1
  • 7

1 Answers1

1

No. The generic instance URLs are shared across many organizations. This cluster is known as a "pod." If you want a unique identifier for a given user, use the Identity URL you get when you log in via OAuth (it looks like /id/00Dxxx/005xxx). This is a globally unique identifier for a given user that will never change, even if they change their username or password. If the user exists in different orgs (e.g. with Sandboxes), the 00D part will still be unique for that user, so you can tell different instances apart.

sfdcfox
  • 489,769
  • 21
  • 458
  • 806
  • When you use the term user, could you elaborate; is this the user that consented the OAuth screen? I'm looking for something unique that can be tied to the whole org/instance. In case another user in that org triggers an apex script, I need to identify this whole organization in my external app. – rosghub Aug 11 '20 at 01:54
  • 2
    @jefferson That is the Organization ID (oid), beginning with 00D. It is guaranteed to be unique for that org (and is also conveniently part of the Identity URL). – sfdcfox Aug 11 '20 at 01:57
  • I see. That should work perfectly for my application. Thank you (again!) – rosghub Aug 11 '20 at 01:59
  • @sdfcfox if you don't mind another question; do you know why in the identity URL the org ID has a few extra characters appended on the end when compared to my 'salesforce.com organization ID' found in company information? – rosghub Aug 11 '20 at 02:07
  • 2
    @jefferson See this answer that explains what the bits and pieces are. Basically, they are parity bits for case-insensitive databases to make sense of Salesforce's case-sensitive IDs. – sfdcfox Aug 11 '20 at 02:11