Send information from one system to another using Postman Flows

Developers often integrate multiple APIs to leverage their individual features. For example, you can get customer profiles from a payment services provider like Stripe and add those profiles as contacts on a marketing platform like Brevo. This tutorial shows you how to do this with Postman Flows.

Goal

Create a Flow that gets a list of customer profiles from Stripe and adds them as contacts to a database in Brevo.

Prerequisites

  • A Stripe account and API key.
  • At least 15 Stripe customers.
  • A Brevo account and API key.

Create the Flow

The first step is to fork (copy) the collections and the environment the Flow will use, then add your API keys to the environment. You could create these requests, collections, and environment, but using existing ones saves time. From the Integration Flows public workspace, fork the Brevo API collection, the Stripe API collection, and the Stripe + Brevo environment to your workspace.

Creating requests is beyond the scope of this tutorial, but you can learn more about creating requests here.

The collections contain the requests that will do the following:

  • Get all the customer profiles from the Stripe API in a single response
  • Divide the response into pages
  • Post the profiles to the Brevo API as contacts

The collections and the environment also contain variables used by the requests.

Create a new Flow and add a Send Request block, then add a GET request by selecting Select a request > Stripe API > Customers > List all customers. Select Add environment > Stripe + Brevo. The Send Request block shows three variables, provided by the GET request. The baseUrl and stripe_secret_key variables are populated automatically from values stored in the request's collection and environment. You can hover over them to see their values and scope. For the limit variable, enter 5 to specify how many contacts to include in each page of results. This tutorial uses 15 contacts, so a limit of 5 will send three pages of results.

Create a new Flow

Connect the Send Request block's Success output to a Select block to check the response's has_more field, which is true or false. If this field's value is true, then there is another page of results to be sent. If it's false, the Flow has reached the end of the customer contacts list.

Select body.has_more

Connect the Send Request block's Success output to another Select block to get the response's data object.

Select body.data

Connect the has_more Select block to an If block's key input and rename value1 to has_more. Select Write an FQL condition and enter has_more. Connect the body.data Select block to the If block's Data input.

Add an If block

Connect an Evaluate block to the If block's TRUE output. Rename value1 to contacts. Select Start writing an FQL query and enter contacts[$count(`contacts`)-1].id. This gets the ID of the last object when there is at least one more contact in the original response.

Add an Evaluate block

Connect a Send Request block to the Evaluate block's Result output and select Select a request > Stripe API > Customers > List all customers pagination. The block automatically selects the Stripe + Brevo environment. Enter 5 for the limit variable.

Connect the Evaluate block's Result output to the starting_after variable in the Send Request block. Then connect the Send Request block's Success output to both the body.has_next and the body.data Select blocks' inputs.

Add another Send Request block

Connect the If block's TRUE and FALSE outputs to a For block. Then connect the For block's output to a Send Request block.

Add a For block

In the Send Request block, select Select a request > Brevo > Contact management > Contacts > POST Create a contact. Select Add environment > Stripe + Brevo.

Select the POST request

Connect the For block's Item output to the email and first_name variables' inputs. Select name for the first_name variable and email for the email variable.

Set variables

Run the Flow and confirm the records are added to Brevo.

Run the Flow and verify contacts

Last modified: 2024/06/05