Create Apex Class
sf_create_apex_classCreate and deploy an Apex class to Salesforce via Metadata API. Accepts full source code, supports service, batch, schedulable, queueable, and test classes, including Agentforce actions with @InvocableMethod.
Instructions
Creates and deploys an Apex class to the Salesforce org using the Metadata API. Accepts the full Apex source code including the class declaration. Use for any type of Apex class: service classes, controllers, batch classes, schedulable classes, queueable classes, test utilities, etc. IMPORTANT — If this class will be used as an Agentforce agent action: it MUST contain a public static method annotated with @InvocableMethod. Classes without @InvocableMethod cannot be invoked by agents and will silently fail at runtime. Example minimum structure: public class MyClass { @InvocableMethod(label='Do Thing' description='Does the thing') public static List doThing(List input) { ... } }
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| classBody | Yes | Full Apex class source code including the class declaration | |
| className | Yes | Apex class name, e.g. 'AccountService' | |
| apiVersion | No | API version for this class, e.g. '66.0' | 66.0 |