Asynchronous Callback Operations Using Apex

Use Apex to create, test, and monitor asynchronous callbacks. Callbacks are right for integrations that require potentially delayed responses of more than 120 seconds from an external source. For example, a mortgage application API, a shipping notification API, or a payment confirmation API.

Required Editions

Available in: Lightning Experience
Available in: Enterprise, Performance, Unlimited, and Developer Editions
Note
Note External Services' asynchronous callback operations are supported in Apex but not in Flow.
  • How External Services Asynchronous Callbacks Work
    External Services asynchronous operations are described in an OpenAPI 3.x compliant specification with a callback operation. Asynchronous operations are registered by the system as a special type of invokable action that allows for longer response times. In contrast, External Services synchronous operations time out after 120 seconds. With asynchronous operations, you use Apex to define the callback and the time out for the delayed asynchronous response.
  • Validate Support for Callback URL Expressions
    Verify that your callback URL expression is supported and registered by External Services as an asynchronous action.
  • Use Apex to Create an Asynchronous Callout to an External Service
    When you register a schema containing a callback, External Services creates an invocable Apex operation with an automatically generated Apex class. Salesforce creates a callback URL on the asynchronous callout (initial callout) that’s read-only. Create an Apex client that’s capable of handling the callback by using the generated Apex interfaces. The client waits for an asynchronous response from the external system for an extended time (up to twenty-four hours).
  • Edit an Asynchronous Callout Class Definition
    To edit an External Services asynchronous callback class, a related background operation job can't be running.
  • Create Unit Testing for Asynchronous Callouts
    You can use the ExternalServiceTest method to mock callback and asynchronous responses.
  • Monitor and Debug Asynchronous Callouts
    Asynchronous callouts are monitored as jobs using the Background Operations app or with Apex log lines in the Developer Console. To debug your code at runtime, use Apex log lines.