Comprehensive Guide to Salesforce Object Key Prefix List in 2025

Understanding the Object Key Prefix List is crucial for developers, administrators, and architects in the Salesforce ecosystem. These prefixes, the first three characters of Salesforce record IDs, identify the type of object a record belongs to. This knowledge is essential for tasks like building integrations, writing Apex code, and troubleshooting issues.

This comprehensive guide delves into the Salesforce Object Key Prefix List, providing trending updates, practical examples, and answers to frequently asked questions.​

Salesforce Object Key Prefix List

Salesforce Object Key Prefix List 2025

What is the Salesforce Object Key Prefix?

Salesforce record IDs are either 15-character (case-sensitive) or 18-character (case-insensitive). The first three characters of these IDs, known as the key prefix, denote the object type. For instance, the ID 0012w00000BvJt0 begins with 001, indicating it’s an Account record.​

This prefix system is pivotal for various Salesforce operations, including:​

  • API Integrations: Determining the object type when processing records.
  • Apex Development: Writing dynamic code that handles different object types.
  • Troubleshooting: Identifying object types in error messages or logs.​

Salesforce Object Key Prefix List (2025)

Below is an updated list of standard Salesforce object key prefixes:​

PrefixObject Type
001Account
003Contact
005User
006Opportunity
007Activity
00BListView
00DOrganization
00EUserRole
00GGroup
00IPartner
00OReport
00PAttachment
00QLead
00TTask
00UEvent
00XEmailTemplate
00eProfile
00hPage Layout
01sPricebook2
01uPricebookEntry
01tProduct2
00kOpportunityLineItem
00lFolder
00vCampaignMember
01ZDashboard
01aDashboardComponent
02cSharing Rule
01pApexClass
01qApexTrigger
03uUserPreference
800Contract
801Order
802OrderItem
806Approval

This list encompasses both standard and custom objects. For a comprehensive list, including custom objects, you can query the EntityDefinition object in Salesforce:​

SELECT Label, KeyPrefix FROM EntityDefinition

This SOQL query retrieves the label and key prefix for all objects in your Salesforce org. Note that some orgs may have a large number of objects, so consider using LIMIT or WHERE clauses to manage the results.

How to Retrieve Object Prefix Using Apex

To dynamically retrieve the key prefix of an object in Apex, you can use the following code snippet:​

String keyPrefix = Account.sObjectType.getDescribe().getKeyPrefix();

System.debug('Account Key Prefix: ' + keyPrefix);

This code retrieves the key prefix for the Account object. Replace Account with any other sObject to get its key prefix.​

Common Use Cases for Key Prefixes

Understanding and utilizing key prefixes can enhance your Salesforce development and administration tasks:

1. API Integrations

When integrating Salesforce with external systems, key prefixes help determine the object type of incoming records. For example, if an external system sends a record with ID 0032w00000BvJt0, the 003 prefix indicates it’s a Contact record.​

2. Apex Development

In Apex, you can write dynamic code that adapts based on the object type. For instance, to handle different objects in a generic method, you can check the key prefix:​

String prefix = recordId.substring(0, 3);

if (prefix == '001') {

    // Handle Account

} else if (prefix == '003') {

    // Handle Contact

}

3. Troubleshooting

When encountering errors or logs with record IDs, the key prefix allows you to quickly identify the object type. This can expedite the troubleshooting process.​

Salesforce Tools to Work with Object Prefixes

Here are some modern tools and Salesforce features gaining popularity in 2025 for working with key prefixes:

1. Salesforce CLI & SFDX

Using the Salesforce CLI (sfdx) combined with Salesforce DX, developers can now script automated discovery of object metadata (including key prefixes):

sfdx force:schema:sobject:list

sfdx force:schema:sobject:describe -s Account

2. Salesforce GraphQL API (Beta)

The GraphQL API is a cutting-edge interface that allows more efficient data fetching. Although it doesn’t expose key prefixes directly yet, it complements object-level querying for better UX and metadata discovery.

Summary

The Salesforce Object Key Prefix List identifies each object type by the first 3 characters of a record ID (e.g., 001 = Account, 003 = Contact). It’s essential for Apex coding, API integrations, and debugging. You can retrieve prefixes using SOQL or Apex for dynamic and scalable development. Understanding key prefixes boosts efficiency, reduces errors, and supports smarter automation in Salesforce.

FAQs

Q1: Why are there 15-character and 18-character Salesforce IDs?

Salesforce uses 15-character IDs in the user interface, which are case-sensitive. The 18-character IDs, used in the API, are case-insensitive and include an additional 3 characters to ensure uniqueness across different systems.​

Q2: How can I convert a 15-character ID to an 18-character ID?

Salesforce provides a method to convert 15-character IDs to 18-character IDs. However, it’s recommended to use the 18-character ID in API calls to avoid case sensitivity issues.​

Q3: Can I modify the key prefix for custom objects?

No, Salesforce assigns a unique key prefix to each custom object, and this prefix cannot be changed.​

Q4: How can I find the key prefix for a custom object?

You can find the key prefix for a custom object by querying the EntityDefinition object with a SOQL query like this:

SELECT QualifiedApiName, KeyPrefix FROM EntityDefinition WHERE IsCustomizable = TRUE AND KeyPrefix != null

Or in Developer Console or Workbench, run:

SELECT DeveloperName, KeyPrefix FROM EntityDefinition WHERE NamespacePrefix = null AND KeyPrefix != null

This will list all custom and standard objects along with their unique key prefixes.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top