Salesforce Ids are central to the operation of your Salesforce org, and there’s a pattern to how they’re constructed, so we’ll look into what makes up a Salesforce Id. They are the primary keys that identify the metadata and data records that are relevant to the operations of your specific Salesforce org.
In a Salesforce multitenant environment, where your data is stored with other organisation’s data, record queries are constructed with a record Id and your org Id on the fly to allow you to find your data. Each Record Id is 15 characters, and is broken down into chunks of characters, where each character can be alphanumeric, capitalised, or uncapitalised.
You may find yourself coming across Salesforce Ids with 18 characters, which is a case-safe version of the underlying 15 character Id. These Ids include a three character checksum which identify the capitalisations of the letters in the Id for systems that don’t recognise case sensitive Ids (i.e. Access). Salesforce recommends the use of the 18-character Id.
The first three characters are the Id of the entity (or object) that the record lives in. In our example Id, “001” tells us that we’ll be accessing our account object to find our record. Salesforce has a handy entity prefix decoder help article on this page.
The fourth and fifth characters are used to identify the instance where the record was created. Salesforce may undertake migrations between instances from time to time.
The sixth character is currently not used and is reserved for use at a later date.
The last nine characters are used to identify the record within the relevant entity. This should give you enough alphanumeric, case-sensitive, unique combinations that you’re really never likely to ever get close to using them all up.