---
schema_version: "1"
id: 137604582bc85bc32ea7179c7012a8951f9b0eaa19f25d84249037e2ef859db9
title: Manage External Inventory with HTTP Callout Action Example
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/platform/264-0-0/automate_flow_http_callout_example.md
canonical_url: https://help.salesforce.com/s/articleView?id=platform.automate_flow_http_callout_example.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 7b49a93f75911a55d3a0e535b7f5974e6acbdb4c3f09a9ceccb773563f7a4a9f
description: This example reviews your store's inventory levels and make an HTTP callout to your supplier's API to place orders when inventory is low.
products:
  - Flow Builder
  - Salesforce Platform
release: "264"
---
# Manage External Inventory with HTTP Callout Action Example

This example reviews your store's inventory levels and make an HTTP callout to your supplier's API to place orders when inventory is low.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: Lightning Experience</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;"><a href="https://help.salesforce.com/s/articleView?id=platform.flow_ref_supported_editions.htm&amp;release=264.0.0&amp;type=5" title="Learn about the editions and user interfaces that support Flow Builder. Some Flow Builder features integrate with other Salesforce products that require additional licenses.">View supported editions.</a></td></tr></tbody></table>

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small permission">
        <colgroup>
          <col style="width:50%">
          <col style="width:50%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="colgroup" class="slds-cell-wrap" colspan="2" style="text-align:left;vertical-align:top;" id="d62820e65">User Permissions Needed</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d62820e65 ">To open, edit, create, activate or
              deactivate a flow using all flow types, elements, and features available in Flow
              Builder, including Einstein and Agentforce for Flow:</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d62820e65 ">Manage Flow</td>

          </tr>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d62820e65 ">To create an external credential, a named credential, and an HTTP callout
              action:</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d62820e65 ">Customize Application</td>

          </tr>
        </tbody>
      </table>

Let's say that you want to make managing your pet store's inventory easier by integrating with your supplier's ordering system so that you can place orders in real time. You want to create a flow that reviews your inventory levels and triggers a call to your supplier's API when they're low. When you click Submit Order, it prompts a real-time API call that automatically places your order.

Before you configure an HTTP callout action:

- Create an external credential and a named credential so that the external service can connect to the API. See [Guidelines for Authenticating HTTP Callout Actions](https://help.salesforce.com/s/articleView?id=platform.flow_http_callout_guidelines_authenticating.htm&release=264.0.0&type=5 "Before you configure an HTTP Callout action within Flow Builder, set up a named credential to authenticate requests to the external system. From Setup, follow these guidelines to create a permission set, auth provider, external credential, and named credential, in that order; then grant users access to the User Credentials object."). In this example, the external credential is PetStore and the named credential is Acme Pet Supplies.
- Prepare a sample API response in JSON format. If a sample doesn't exist in the API's documentation, you can use a third-party API platform to retrieve a response. In this example, the sample API response used is:
    
    ```
    {
      "id": 0,
      "petId": 0,
      "quantity": 0,
      "shipDate": "2024-10-09T08:49:33.605Z",
      "status": "placed",
      "complete": true
    }
    ```
- Start with an API that's well documented. If details such as field requirements or definitions are inaccurate or outdated, it can take time to debug.

1. Open the Flows list view.
    
    - From the Automation app, select the **Flows** tab.
    - From the **Flows** tab in any Lightning app, click the actions menu and select **Open Flow**.
    - From Setup, in the Quick Find box, enter Flows, and then select **Flows**.
    
    Note that the Automation app and Flows tab options don't require Setup access.
2. Create a screen flow.
    - From the Automation app, click **New** | **Screen** | **Screen Flow**.
    - From Setup, click **New Flow** | **Screen** | **Screen Flow**.
3. Add the Get Records element and configure it.
    
    1. For Label, enter Get Pet Inventory.
    2. For Object, select **Inventory**.
    3. For Condition Requirements, select **None—Get All Inventory Records**.
    4. For How Many Records to Store, select **All Records**.
    
    ![Get Records element configuration](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/platform_automation/images/flow/flow_http_callout_getrecords.png)
4. After the Get Pet Inventory element, add a Screen element and configure it.
    1. For Label, enter Reorder Pet Inventory.
    2. For API Name, enter Reorder\_Pet\_Inventory.
    3. Under Configure Header, enable **Show Header**.
    4. Under Configure Footer, enable **Show Footer**.
5. Add a Section component to the Reorder Pet Inventory screen and configure it.
    1. Enable **Include Header**.
    2. For Label, enter Pet Inventory.
    3. For API Name, enter Available\_Pets.
    4. Under Configure columns, add the required columns, and set the width.
6. Add a Data Table component as a child of the Pet Inventory section and configure it.
    1. For API Name, enter petTable.
    2. For Label, enter Available Pets.
    3. Enable **Use Label as the table title**.
    4. For Source Collection under Configure Data Source, enter {!Get\_Pet\_Inventory}.
    5. Enable **Show search bar**.
    6. Under Configure Columns, add required columns.
7. Add another Section component as a child of the Reorder Pet Inventory screen and configure it.
    1. Enable **Include Header**.
    2. For Label, enter Restock Selected Pet.
    3. For API Name, enter Reorder\_Information.
    4. Under Configure Columns, add the required columns, and set their width.
8. Add a Text component as a child of the Restock Selected Pet section and enter these values.
    1. For Label, enter Selected Pet.
    2. For API Name, enter Selected\_Pet.
    3. For Default Value, enter {!petTable.firstSelectedRow.Name}.
9. Add a Currency component as a child of the Restock Selected Pet section and enter these values.
    1. For Label, enter Cost Per Unit.
    2. For API Name, enter Cost\_Per\_Unit.
    3. For Default Value, enter {!petTable.firstSelectedRow.Current\_MSRP\_\_c}.
10. Add a Number component as a child of the Restock Selected Pet section and enter these values.
    1. For Label, enter Order Quantity.
    2. For API Name, enter Order\_Quantity.
    3. For Decimal Places, enter 0.
11. Add another Number component as a child of the Restock Selected Pet section and enter these values.
    
    1. For Label, enter Total Cost.
    2. For API Name, enter Total\_Cost.
    3. For Default Value, enter {!formulaTotalCost}.
    4. For Decimal Places, enter 2.
    
    ![Screen element configuration](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/platform_automation/images/flow/flow_http_callout_screen_element.png)
12. After the Screen element, add an Action element and configure it.
    1. Click **Create HTTP Callout**.
        
        ![A list of action categories in Action element.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/platform_automation/images/flow/flow_http_callout_action.png)
    2. In Create External Service, for Name, enter OrderPetTest.
    3. For Named Credential, select **Acme Pet Supplies**.
        
        The URL associated with the credential is autopopulated.
    4. Click **Next**.
    5. In Configure Invocable Action, for Label, enter Order Pet.
    6. For Method, select **POST**.
    7. For URL Path, enter /store/order.
    8. Click **Next**.
        
        ![HTTP Callout configuration](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/platform_automation/images/flow/flow_http_callout_invocable_action.png)
    9. For Sample JSON Request, enter the JSON snippet required for this example.
    10. To confirm data structure parameters, click **Review**.
        
        ![Sample JSON Request configuration](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/platform_automation/images/flow/flow_http_callout_json.png)
    11. In Select Sample Response Method, select **Connect for Schema**, and then click **Next**.
    12. Click **Save**.
    13. For Label, enter Callout to Order Pets.
    14. For API Name, enter Callout\_to\_Order\_Pets.
    15. In Set Body Request, for Value, enter {!Order\_Pet\_Input\_Test}.
13. Before the Callout to Order Pets action, add an Assignment element and configure it.
    
    1. For Label, enter Assign Callout Request Fields.
    2. For API Name, enter Assign\_Callout\_Request\_Fields.
    3. For Set Variable Values, enter {!Order\_Pet\_Input\_Test.id} **Equals**. {!petTable.firstSelectedRow.Recommended\_Reorder\_Quantity\_\_c}.
    4. Click **Add Assignment**, and enter {!Order\_Pet\_Input\_Test.quantity} **Equals** {!Order\_Quantity}.
    5. Click **Add Assignment**, and enter {!Order\_Pet\_Input\_Test.shipDate} **Equals** {!$Flow.CurrentDate}.
    6. Click **Add Assignment**, and enter {!Order\_Pet\_Input\_Test.status} **Equals** Placed.
    
    ![Assignment element configuration](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/platform_automation/images/flow/flow_http_callout_assignment.png)
14. After the Callout to Order Pets action, add a Decision element and configure it.
    
    1. For Label, enter Was Callout Successful?.
    2. For API Name, enter Was\_Callout\_Successful.
    3. For Select Decision Logic, select **Define Manually (Default)**.
    4. For the New Outcome label, enter Callout Successful.
    5. For Condition Requirements to Execute Outcome, select **All Conditions Are Met (AND)**.
    6. For Resources, enter {!Callout\_to\_Order\_Pets.responseCode}**Greater Than or Equal** 200.
    7. Click **Add Resources**, enter {!Callout\_to\_Order\_Pets.responseCode} **Lesser Than or Equal** 200.
    8. Click **Default Outcome**.
    9. For Label, delete the text, and then enter Callout Not Successful.
    
    ![Decision element configuration](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/platform_automation/images/flow/flow_http_callout_decision.png)
15. On the Callout Not Successful outcome path, add a Screen element and configure it.
    1. For Label, enter Error Screen.
    2. For API Name, enter Error\_Screen.
    3. Under Configure Header, enable **Show Header**.
    4. Under Configure Footer, enable **Show Footer**.
16. On the Callout Successful outcome path, add an Update Records element and configure it.
    
    1. For Label, enter Update Inventory Quantity on Hand.
    2. For API Name, enter Update\_Inventory\_Quantity\_on\_Hand.
    3. For ​​How to Find Records to Update and Set Their Values, select **Specify conditions to identify records, and set fields individually**.
    4. For Object, select **Inventory**.
    5. For Condition Requirements to Update Records in Filter Inventory Records, select **All Conditions Are Met (AND)**.
    6. For Field, Operator, and Value, select **Record ID** **Equals** {!petTable.firstSelectedRow.Id}.
    7. In Set Field Values for the Inventory Records, for Field, select **Quantity on Order**.
    8. In Set Field Values for the Inventory Records, for Value, enter ​​{!UpdateQuantityOnHand}.
    
    ![Update Records element configuration](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/platform_automation/images/flow/flow_http_callout_decision_update_records.png)
17. On the Callout Successful outcome path, next to the Update Inventory Quantity on Hand element, add a Screen element and configure it.
    
    1. For Label, enter Order Placed.
    2. For API Name, enter Order\_Placed.
    3. Under Configure Footer, enable **Show Footer**.
    4. For Navigation, select **Use a custom label**.
    5. For Next or Finish Button Label, enter OK.
    6. Hide the Previous and Pause buttons.
    7. Add a Display component to the Screen element.
    8. For the API Name of the Display component, enter SuccessDisplayHeader.
    9. For Description of the Display component, enter Your order was successful!.
    10. Add a Section component to the Screen element.
    11. For Label of the Section component, enter ​​Order Summary.
    12. For the API Name of the Section component, enter OrderSummary.
    13. Set the Column width based on the requirement.
    14. Add required Display components as children of the Section, and configure them based on the requirement.
    
    ![Screen element configuration](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/platform_automation/images/flow/flow_http_callout_decision_screen.png)
18. Save the flow, and then click **Debug** to troubleshoot the flow for any errors.
19. Click **Run**.
20. Select an inventory item that you want to order.
    
    ![Debug screen of HTTP Callout example.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/platform_automation/images/flow/flow_http_callout_debug_screen.png)
21. Enter an order quantity, and then click **Submit Order**.
    
    The order is placed successfully. If the flow fails, troubleshoot the flow errors.
22. (Optional) To restart the flow by using the same or different values for the input variables, click **Change Inputs or Run Again**.
    
    You can't convert the debug run to a test in the screen flow.
    
    ![HTTP Callout Example](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/platform_automation/images/flow/flow_http_callout_example.png)

#### See Also

- [HTTP Callout Considerations and Limits](https://help.salesforce.com/s/articleView?id=platform.flow_http_callout_considerations.htm&release=264.0.0&type=5 "When using HTTP Callout, keep these considerations and limits in mind.")