Newer Version Available

This content describes an older version of this product. View Latest

Apex Actions

Invoke Apex methods annotated with @InvocableMethod and include custom parameters with @InvocableVariable.

This object is available in API version 33.0 and later.

Supported REST HTTP Methods

URI
Get a list of available Apex actions:
/services/data/vXX.X/actions/custom/apex
Get information about a specific Apex action:
/services/data/vXX.X/actions/custom/apex/action_name
Formats
JSON, XML
HTTP Methods
GET, HEAD, POST
Authentication
Authorization: Bearer token
Parameters
None
Example
This example invokes the Apex action called ActionTest, which takes a list of IDs and returns a list of associated account names. The top-level key name in the JSON request body must be inputs.
Here is the Apex code:

The resource is the name of the Apex class, not the Apex method. In this example, the resource is /ActionTest, not /getAccountNames.

Note

Notes
  • Describe and invoke for an Apex action respect the profile access for the Apex class. If you don’t have access, an error is issued.
  • If you add an Apex action to a flow, and then remove the @InvocableMethod annotation from the Apex class, you get a runtime error in the flow.
  • If an Apex action is used in a flow, packageable components that reference these elements aren’t automatically included in the package. For example, if you use an email alert, you must manually add the email template that is used by that email alert. To deploy the package successfully, manually add those referenced components to the package.
  • An Apex invocable action can be declared public or global in a managed package. However, that action doesn’t appear in Flow Builder’s list of available Apex actions. These invocable actions can still be referred to by flows within the same managed package. Global Apex invocable actions in a managed package can be used in flows outside the managed package, anywhere in the organization, and appear in Flow Builder’s list of available Apex actions.

Inputs

Supply input values that correspond to the Apex action.

  • A POST request body must use the JSON format specified in Invoking Actions.
  • Apex methods annotated with @InvocableMethod must take a List as an input and return a List or Null. For more information, see @InvocableMethod Annotation in the Apex Developer Guide.
  • Only the following primitive types are supported as inputs in a POST request body:
    • Blob
    • Boolean
    • Date
    • Datetime
    • Decimal
    • Double
    • ID
    • Integer
    • Long
    • String
    • Time
  • A specific sObject type– the generic sObject type is not supported.
  • A user-defined type, containing variables of the supported types and with the InvocableVariable annotation. Create a custom global or public Apex class to implement your data type, and make sure your class contains at least one member variable with the invocable variable annotation.

For more information, see the @InvocableMethod and @InvocableVariable annotations in the Apex Developer Guide.

Outputs

The Apex InvocableMethod determines the output values.