Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
Retrieve Apex Type Information with the Symbols Resource (Beta)
Syntax
- URI: /services/data/vXX.X/tooling/symbols/
- HTTPS Method: GET
- Authentication: Authorization: Bearer token
- Format: JSON
Request Query Parameters
| Name | Type | Description |
|---|---|---|
| category | String |
Required. The category of Apex types to retrieve. Possible values are:
|
| namespace | String | Optional. Filters the results to a specific namespace. To retrieve only types in the local org namespace, pass an empty string (namespace=). If this parameter is omitted, Apex types from all namespaces in the category are returned. |
| name | String | Optional. Filters the results to the specified Apex type name. If both namespace and name are specified, the results must match both conditions. |
Request Body Properties
None.
Response Body Properties
| Name | Type | Description |
|---|---|---|
| typeStubs | Object[] | An array of Apex types. Each object describes one Apex class, interface, enum, or trigger, including members such as fields, properties, methods, annotations, and documentation when available. |
Each object in the typeStubs array can include these properties.
| Name | Type | Description |
|---|---|---|
| name | String | The developer name of the Apex type stub. |
| namespacePrefix | String | The namespace of the Apex type, or null if the type doesn't have a namespace. |
| kind | String | The kind of Apex type. Possible values are CLASS, INTERFACE, ENUM, and TRIGGER. |
| modifiers | String[] | The modifiers applied to the type, such as public, global, virtual, or abstract. |
| annotations | Object[] | The annotations applied to the type, such as AuraEnabled, IsTest, or NamespaceAccessible. |
| superClass | Object | A type reference for the superclass, or null if the type doesn't have a superclass. |
| interfaces | Object[] | Type references for interfaces implemented by the type. |
| fields | Object[] | The fields declared on the type. A field is a variable declared at the type level instead of inside a method. |
| properties | Object[] | The properties declared on the type. |
| methods | Object[] | The methods and constructors declared on the type. |
| innerTypes | Object[] | Nested Apex types declared within the type. Each nested type uses the same structure as a top-level type stub. |
| triggerOperations | String[] | For triggers, the trigger operations, such as BEFORE UPDATE. The value is null for non-trigger types. |
| documentation | String | Documentation for the type. For built-in types, this property can include official usage guidance. For custom types, this property can include ApexDoc comments. In API version 68.0, ApexDoc comments from managed packages aren't returned. |
| triggerObjectType | Object | For triggers, a type reference for the sObject that the trigger is defined on. The value is null for non-trigger types. |
| compileError | String | A compilation error message if symbol extraction encountered a compile error for the type; otherwise, null. |
Annotations Array Properties
Each object in an annotations array can include these properties.
| Name | Type | Description |
|---|---|---|
| name | String | The annotation name. |
| parameters | Object[] | The annotation parameters. |
| documentation | String | Documentation for the annotation, if available. |
Annotation Parameters Array Properties
Each object in an annotation parameters array can include these properties.
| Name | Type | Description |
|---|---|---|
| name | String | The parameter name. |
| type | Object | A type reference for the parameter type. |
| value | String | The parameter value. |
Fields Array Properties
Each object in the fields array can include these properties.
| Name | Type | Description |
|---|---|---|
| name | String | The field name. |
| type | Object | A type reference for the field type. |
| modifiers | String[] | The field modifiers. |
| annotations | Object[] | The field annotations. |
| documentation | String | Documentation for the field, if available. |
| definingType | Object | A type reference for the Apex type that originally declares this field. This property is set only for inherited fields and is omitted when the field is declared directly on the enclosing type. |
Properties Array Properties
Each object in the properties array can include these properties.
| Name | Type | Description |
|---|---|---|
| name | String | The property name. |
| type | Object | A type reference for the property type. |
| modifiers | String[] | The property modifiers. |
| annotations | Object[] | The property annotations. |
| getter | Object | Present if the property has a get accessor. The object includes a modifiers array and a documentation property. |
| setter | Object | Present if the property has a set accessor. The object includes a modifiers array and a documentation property. |
| documentation | String | Documentation for the property, if available. |
| definingType | Object | A type reference for the Apex type that originally declares this property. This property is set only for inherited properties and is omitted when the property is declared directly on the enclosing type. |
Methods Array Properties
Each object in the methods array can include these properties.
| Name | Type | Description |
|---|---|---|
| name | String | The method or constructor name. |
| isConstructor | Boolean | true if the member is a constructor; otherwise, null. |
| returnType | Object | A type reference for the return type. The value is null for constructors. |
| modifiers | String[] | The method modifiers. |
| annotations | Object[] | The method annotations. |
| parameters | Object[] | The method parameters. |
| documentation | String | Documentation for the method, if available. |
| definingType | Object | A type reference for the Apex type that originally declares this method. This property is set only for inherited methods and is omitted when the method is declared directly on the enclosing type. |
Methods Parameter Array Properties
Each object in a method parameters array can include these properties.
| Name | Type | Description |
|---|---|---|
| name | String | The parameter name. |
| type | Object | A type reference for the parameter type. |
| annotations | Object[] | The parameter annotations. |
| documentation | String | Documentation for the parameter, if available. |
Type Reference Properties
Several response properties use a nested type reference object instead of returning a type as a string. This structure separates the type into parts that developer tools can consume.
Type references appear in these properties:
- superClass
- Objects in the interfaces array
- The type property of a field or property
- A method's returnType property
- The definingType property of an inherited field, method, or property
- A parameter's type property
- triggerObjectType
Each type reference object can include these properties.
| Name | Type | Description |
|---|---|---|
| namespacePrefix | String | The namespace of the referenced type, or null if the type doesn't have a namespace. |
| name | String | The name of the referenced type. |
| typeParameters | Object[] | Type references for generic type arguments, such as String in List<String>. The value is null if the type isn't parameterized. |
Usage
Use the Apex Symbol API to build tools that:
- Provide code completion with full generic type support. For example, List<Account> displays with readable type parameters instead of internal encoding.
- Display official documentation for built-in types, including usage guidance and examples.
- Display ApexDoc comments for custom types.
- Show constructor signatures with parameter types, annotations, and modifiers.
- Identify trigger operations, such as before insert and after update, without parsing source code.
- Access type information across all standard Apex namespaces, such as the System, Database, and Messaging namespaces.
Considerations
- The API enforces a concurrency limit of one request per org. If a request is in progress and a second request is made for the same org, the second request fails. Avoid parallel calls to this API from the same org.
- In API version 68.0, ApexDoc comments from managed packages aren't returned. Packaged ApexDoc comments for global identifiers are planned for a later API version.
Example
Example Request: Retrieve the built-in ApexPages type in the System namespace.
1GET "https://MyDomain.my.salesforce.com/services/data/v68.0/tooling/symbols?category=builtin&namespace=System&name=ApexPages"Example Response Body (excerpt)
1{
2 "typeStubs": [
3 {
4 "name": "ApexPages",
5 "namespacePrefix": "System",
6 "kind": "CLASS",
7 "modifiers": [
8 "global"
9 ],
10 "annotations": [],
11 "superClass": null,
12 "interfaces": [],
13 "fields": [],
14 "properties": [],
15 "methods": [
16 {
17 "name": "addMessage",
18 "isConstructor": null,
19 "returnType": {
20 "namespacePrefix": null,
21 "name": "void",
22 "typeParameters": null
23 },
24 "modifiers": [
25 "global",
26 "static"
27 ],
28 "annotations": [],
29 "parameters": [
30 {
31 "name": "message",
32 "type": {
33 "namespacePrefix": "ApexPages",
34 "name": "Message",
35 "typeParameters": null
36 },
37 "annotations": [],
38 "documentation": ""
39 }
40 ],
41 "documentation": "Add a message to the current page context."
42 }
43 ],
44 "innerTypes": [],
45 "triggerOperations": null,
46 "documentation": "Use ApexPages to add and check for messages associated...",
47 "triggerObjectType": null,
48 "compileError": null
49 }
50 ]
51}