Step By Step Guide to Calling Flow From an API

Step By Step Guide to Calling Flow From an API

A Flow can be invoked from multiple places. You can invoke it from a button, embed it on your pages, invoke it when DML operations are performed, schedule to run it or even invoke it through REST API call.

In this step-by-step guide, you will learn how to call a Flow from an API, how to pass parameters to the Flow and how Flow will return the values back to the API

Not an “All Access” Pass Member Yet?

Get Download Access to this & 150+ More Step-by-Step Guides with “All Access” Pass. A simple and single plan to access our entire library of courses, guides, workshops & masterclasses on Salesforce.

Introducing Mastering Salesforce Flows Training Course

Liked this post? We are now offering a complete self-paced, video-based training course on Mastering Salesforce Flows. The course comes with downloadable step-by-step PDF guides, unlimited access, free upgrades, community discussion area, free preview and more. For more details, please click here.

Need Help with Flows?

Need advice on Flows? I also offer advisory & consulting services on Salesforce Flows. So, whether you want to create new Flows or migrate existing automations (Workflow Rules, Process Builder, Triggers) to Flows, I can help you analyze, design, plan & review. To initiate a discussion, please submit the contact form here stating your requirement or schedule a discussion at this URL.

References & Useful URLs

12 thoughts on “Step By Step Guide to Calling Flow From an API”

  1. Hello thanks for the tutorial,

    I’d like to know how to set the statusCode and the response message values in the flow. For example to return a statusCode = 400 and message = ‘Missing required value’ when flow runs and finds out there’s a missing required value.
    All I get is below exception in response :
    [
    {
    “actionName”: “XXX_Flow_Api_Name_XXX”,
    “errors”: [
    {
    “statusCode”: “UNKNOWN_EXCEPTION”,
    “message”: “An error occurred when executing a flow interview.”,
    “fields”: []
    }
    ],
    “isSuccess”: false,
    “outputValues”: null
    }
    ]

  2. Hi,
    This information really helps me to integrate with PBXs.

    Allow me to ask a question regarding slide page 27.
    How can we know the structure of the request body? Where is the structure below defined?
    {
    “inputs” : [ { “xxxx ” : “yyyy” } ]
    }

    Thank you,
    Tetsuro

  3. Hello and thank you for the cool tutorial!

    I would like to handover a record of the standard Contact object (defined as an sObject “sO_Contact” variable in the flow) via JSON. How to put it in the right format for the API to accept it?

    This won’t work:
    [{

    “inputs”: {
    “sO_Contact”: {
    “FirstName”: “Julian”,
    “LastName”: “APIviaSObject3”,
    “Email”: “julian@customer.de”,
    “AccountId”: “0010Q00001ZajJwQAJ”
    }
    }
    }]

    “message”: “Can not deserialize: unexpected array at [line:1, column:1]”,

    1. Hi Julian, It should be formatted like this. I have tested this out and it works.

      {
      "inputs" : [{
      "accountRecord" : {
      "Name" : "Account from API",
      "BillingCountry" : "Singapore"
      }
      }]
      }

  4. Hello Ashish, thank you for this guide.

    I’m able to test a custom, auto launched flow from Workbench like on this guide.

    However, trying to call the endpoint from a Python script gets me a JSON object describing the Flow: “{“allowsTransactionControl”:false,”category”:null,”configurationEditor”:null,”description”….}

    Have you encountered a similar issue, or are Flow APIs only callable from inside Workbench?

    1. Hi Sergio,

      The Flow APIs can be called from anywhere. It is not restricted to Workbench. I am not familiar with Python, but can you try if you are able to make other API calls to the same Salesforce org with the same user credentials and and getting a proper response. If you can run it from Workbench, it should work fine from other places also.

      Regards,
      Ashish

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top
Introducing All Access Pass