Expose Apex logic to Salesforce Flow as an invocable method with typed input and output collections
domain: developer.salesforce.com · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗
In-depth guide
Salesforce Bulk API 2.0 limits — the full failure-mode walkthrough related to developer.salesforce.com, checked against official docs, with linked verified routes.
Steps
Annotate a global or public static Apex method with @InvocableMethod(label='...' description='...' category='...')
Define an inner class annotated with nothing (plain Apex class) to serve as the request type, with each field annotated @InvocableVariable(label='...' required=true/false)
Define a corresponding response inner class with @InvocableVariable-annotated output fields that the flow will read after execution
Declare the method signature as List<ResponseClass> methodName(List<RequestClass> requests) — Flow always passes a list to support bulk invocation
Process all items in the input list in a single method call, using bulkified SOQL and DML as needed, and return a list of responses in the same order as inputs
In Flow Builder, add an Action element, search for the invocable method by its label, map flow variables to input fields, and map output fields back to flow variables
Known gotchas
The method must accept exactly one List parameter and return exactly one List — methods with signatures that deviate from this pattern will not surface in Flow Builder's Action picker
Each input and output field on the inner classes must be a supported Flow data type; unsupported types (e.g., Map, Set, custom non-sObject objects not annotated) cause compile-time or runtime errors
Invocable methods called from a Record-Triggered Flow share the triggering transaction's governor limits; heavy Apex logic inside the method can exhaust SOQL or CPU limits on large bulk operations
Give your agent this knowledge — and 15,600+ more routes
One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp
Need this verified for your stack — or a route we don't have yet?