Skip to main content

Send Salesforce data to an external API from Flow

Build the common pattern where Flow runs an outbound Payload and passes the Salesforce record context into Payloads.

Send Salesforce data to an external API from Flow

This recipe shows the most common outbound pattern: a Salesforce process decides that something should happen, then Flow asks Payloads to call an external API.

Use this pattern when the business trigger lives in Salesforce but the work happens somewhere else. Typical examples are creating a payment session, updating a fulfilment system, sending a customer record to a platform API, or notifying an internal service when a Salesforce record reaches a particular state.

For the full Flow article, see Use Payloads in Flow.

What you are building

The finished setup has four moving parts.

  • An Outbound Payload models the external API request.

  • Dynamic Inputs let Flow pass record-specific values into the run.

  • Data Queries read the Salesforce records needed by the request.

  • The Flow action chooses the Payload, passes Dynamic Inputs, and chooses the firing mode.

The Payload stays responsible for API structure, credentials, mappings, transformations, and the Job trail. Flow stays responsible for timing and business decisions.

Build and test the Payload first

Create an Outbound Payload before opening Flow Builder.

At minimum, configure:

  • Endpoint and Method

  • Credential

  • Timeout

  • Outbound Content Type

  • Dynamic Inputs

  • Data Queries

  • outbound Body, Headers, Parameters, or Modifiers

  • response handling

Use a manual run to prove the Payload works with realistic values. Flow should not be the first place you discover that the request body or Credential is incomplete.

Pass record context as Dynamic Inputs

Dynamic Inputs are the contract between Flow and Payloads.

If the Flow starts from an Opportunity, create a Dynamic Input such as $OPPORTUNITY_ID. The Payload's Data Queries can then filter from that input, and the request body can map fields from the queried Opportunity and its child records.

Do not pass every field as a Dynamic Input. Pass the stable identifier or small set of values the Payload needs to find the right data.

Query the Salesforce data Payloads needs

Create Data Queries on the Payload for the records the external API needs.

For a checkout-style request, the Payload might query the Opportunity and child OpportunityLineItem records. The Opportunity query gives the root transaction context. The line item query gives the array entries for products, quantities, and prices.

For query setup, see Configure Data Queries.

Map the request body

Build the outbound body so it matches the external API.

For simple fields, map body Elements to fields from a single-record Data Query. For repeated items, create an array Element and map that array to the child record query. Elements inside that array can then use fields from the current child record.

The Stripe checkout request body showing a line_items array and mapped child values.

The request body should mirror the API shape, while the mappings decide where each runtime value comes from.

For more detail on array-backed mappings, see Build a parent and child request body and Map outbound request bodies.

Add the Flow action

In Flow Builder, add Payloads: Run Payload.

Choose the Payload, then map the Dynamic Input fields shown by the configuration editor. If the Payload expects $OPPORTUNITY_ID, pass the current Opportunity Id or another Flow variable containing that Id.

The Payloads Run Payload action configured in Flow Builder with a Payload, firing mode, and Dynamic Input value.

The selected Payload controls which Dynamic Inputs the Flow action asks for.

Use Immediately for screen flows when the user needs the result now. For record-triggered flows, put immediate runs on an asynchronous path. Use Queueable Job or Batch Engine when the Flow should hand off the work.

For runtime choices, see Understand runtime behaviour and limits.

Use the Job result

The Flow action returns a Job, a success value, and an error value.

For synchronous runs, use the Job when the Flow needs to branch, show a confirmation, or pass the result into another step. For asynchronous runs, treat success as confirmation that Payloads accepted the work, then inspect the persisted Job after execution.

Test the full path

Run the Flow with a real test record.

Open the Job and check:

  • Dynamic Inputs contain the record Id you expected

  • Data Queries returned the correct records

  • the outbound body matches the external API shape

  • headers and parameters include the Credential output

  • response status is inside the configured success range

  • metrics are acceptable

A Job Metrics modal showing runtime, CPU, Data Query, DML, and heap usage.

The Job proves what Flow passed to Payloads and what Payloads sent to the external API.

If the Job fails, use Troubleshoot failed Jobs.

Did this answer your question?