Salesforce's Flow Builder is a powerful tool that enables you to automate business processes without writing code. In this guide, I'll show you how to leverage this tool to expose Salesforce Flows as API endpoints, allowing other systems to interact with Salesforce without the need for Apex code.
Step 1: Create the Autolaunched Flow
-
Navigate to Flow Builder:
- Go to Setup > Process Automation > Flows.
- Click New Flow.
- Select Autolaunched Flow (No Trigger).
-
Define Input Variables:
- Click New Resource and select Variable.
- Set the API Name to
inputParam
, Data Type to Text, and check the box Available for input.
-
Add Your Logic:
- Add the necessary elements (e.g., Get Records, Update Records, Create Records) to define the logic of your Flow. Use the
inputParam
variable as needed.
- Add the necessary elements (e.g., Get Records, Update Records, Create Records) to define the logic of your Flow. Use the
-
Save and Activate:
- Name your Flow appropriately and save it.
- Click Activate to make your Flow live.
Step 2: Generate the Flow URL
-
Ensure Lightning Runtime for Flows is Enabled:
- Go to Setup > Process Automation Settings.
- Make sure Enable Lightning Runtime for Flows is checked.
-
Construct the Flow URL:
- Navigate to your Flow's details page.
- The URL format to call the Flow is:
https://yourInstance.salesforce.com/services/data/vXX.X/actions/custom/flow/Your_Flow_API_Name
- Replace
yourInstance
with your Salesforce instance (e.g.,na1
,eu2
). - Replace
XX.X
with the API version you want to use (e.g.,v56.0
). - Replace
Your_Flow_API_Name
with the API name of your Flow.
Step 3: Call the Flow from an External System
-
Prepare the HTTP Request:
- The external system can make an HTTP POST request to the Flow URL.
- The request body should include the input parameters in JSON format. For example:
{ "inputs": [ { "inputParam": "Your Input Value" } ] }
-
Sample cURL Command:
- Here's a sample cURL command to invoke the Flow:
curl -X POST https://yourInstance.salesforce.com/services/data/vXX.X/actions/custom/flow/Your_Flow_API_Name \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "inputs": [ { "inputParam": "Your Input Value" } ] }'
Conclusion
By following these steps, you can expose Salesforce Flows as API endpoints, allowing external systems to interact with Salesforce without writing any Apex code. This no-code solution simplifies the integration process, making it more accessible for Salesforce administrators and reducing the dependency on developers.
Embrace the power of Salesforce Flows and explore how this no-code approach can enhance your organization's integration capabilities. If you have any
Top comments (0)