DEV Community

Sushant Khandagale
Sushant Khandagale

Posted on

Exposing Salesforce Flows as API Endpoints: A No-Code Approach

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

  1. Navigate to Flow Builder:

    • Go to Setup > Process Automation > Flows.
    • Click New Flow.
    • Select Autolaunched Flow (No Trigger).
  2. 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.
  3. 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.
  4. Save and Activate:

    • Name your Flow appropriately and save it.
    • Click Activate to make your Flow live.

Step 2: Generate the Flow URL

  1. Ensure Lightning Runtime for Flows is Enabled:

    • Go to Setup > Process Automation Settings.
    • Make sure Enable Lightning Runtime for Flows is checked.
  2. 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

  1. 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"
         }
       ]
     }
    
  2. 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)