Skip to content

FLOW_CallApiAsync

Class · Group: Web Services

apex
global inherited sharing class FLOW_CallApiAsync

Asynchronously invokes web service calls, allowing large or delayed API callouts to be processed outside of immediate flows or triggers. Leverages the adaptive asynchronous processor to manage API requests efficiently.

Since: 1.0

Example:

apex
List<ApiCall__c> apiCalls = new List<ApiCall__c>();
ApiCall__c apiCall = TST_Factory.newOutboundApiCall('API_GetCustomerInfo', recordId, new Map<String, String>{'customerId' => '5678'});
apiCalls.add(apiCall);
FLOW_CallApiAsync.invokeApiCallAsynchronously(apiCalls);

Methods

MethodDescription
global static void invokeApiCallAsynchronously(List<ApiCall__c> apiCalls)Invokes web service calls asynchronously by enqueuing Queueable jobs for each set of API calls.

Method Details

invokeApiCallAsynchronously

apex
@InvocableMethod(category='Api Callouts' description='Queues an HTTP callout asynchronously. Use when a Flow sends data to an external service and does not need to wait for the response.' label='Invoke Callout Asynchronously') global static void invokeApiCallAsynchronously(List<ApiCall__c> apiCalls)

Invokes web service calls asynchronously by enqueuing Queueable jobs for each set of API calls. Falls back to Batch job if Queueable limits are exceeded. The job size is read from AsynchronousJobSetting__mdt.FLOW_CallApiAsync (default: 20) to keep each execution within the 100-callout governor limit.

Parameters:

  • apiCalls (List) - The list of API calls containing details for API callouts.

Since: 1.0

Example:

apex
List<ApiCall__c> apiCalls = new List<ApiCall__c>();
ApiCall__c apiCall = TST_Factory.newOutboundApiCall('API_GetCustomerInfo', null, new Map<String, String>{'customerId' => '5678'});
apiCalls.add(apiCall);
FLOW_CallApiAsync.invokeApiCallAsynchronously(apiCalls);