Querying Entity metadata is useful when you need to build introspection-driven UIs, document the schema, or audit customizations. The Tooling API exposes EntityDefinition and EntityParticle for this purpose.
- Open the Developer Console
Click your avatar, then Developer Console. The Query Editor at the bottom lets you run SOQL against the Tooling API.
- Toggle Use Tooling API
At the top of the Query Editor, check Use Tooling API. This switches the query target from the data layer to the metadata layer.
- Query EntityDefinition
Run: SELECT QualifiedApiName, Label, IsCustomizable FROM EntityDefinition LIMIT 50. The result lists every entity in your org with its API name and label.
- Filter for custom entities
Add a filter: WHERE IsCustomizable = true AND IsCustomSetting = false. This narrows to entities you can customize (standard plus custom objects, excluding custom settings).
- Query EntityParticle for a specific entity
Run: SELECT QualifiedApiName, Label, DataType, Length FROM EntityParticle WHERE EntityDefinition.QualifiedApiName = Account AND IsAccessible = true. The result lists every accessible field on Account.
- Use the results in code or documentation
Export the results to CSV. Feed them into Apex for introspection, generate documentation, or audit which entities have specific fields. EntityDefinition and EntityParticle are the foundation of many third-party governance tools.
Tooling API object exposing object-level metadata. One row per addressable entity in the org.
Tooling API object exposing field-level metadata. Many rows per EntityDefinition.
Apex method returning similar metadata at runtime. Use in Apex; pair with EntityDefinition for governance UIs.
Apex method returning all objects. The runtime equivalent of EntityDefinition.
- Tooling API EntityDefinition does not return platform-managed entities like SharingHierarchy or ContentVersion in some contexts. Add specific filters as needed.
- IsCustomizable does not mean the entity is editable by your user. It means the metadata supports custom field additions. Profile permissions are a separate gate.
- EntityParticle returns archived and deprecated fields. Filter for IsAccessible if you only want fields the current user can see.
- Query limits apply to the Tooling API. Massive metadata queries can hit SOQL row limits; paginate with LIMIT and OFFSET.