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
Create the flow, collections, and environment
-
Open the Integration Flows public workspace and fork the Brevo API collection, the Stripe API collection, and the Stripe + Brevo environment to your workspace.
-
In your workspace, open the Stripe + Brevo environment.
-
Replace the stripe_secret_key variable’s value, your key here, with your Stripe API key.
-
Create a new flow and click Send a request.
Set up the initial Stripe request
-
Click Find or create new request and select Stripe API > Customers > List all customers.
-
Click Add environment and select Stripe + Brevo. The HTTP Request block shows the request’s three variables. The
baseUrlandstripe_secret_keyvariables are populated automatically from values stored in the request’s collection and environment. -
Next to the limit variable, click
Add data blocks and select Number. 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.
Add pagination logic
-
Connect the HTTP Request block’s Success output to a Select block.
-
Click Enter path and enter “body.has_more”.
-
Connect the HTTP Request block’s Success output to another Select block.
-
Click Enter path and enter “body.data”.
-
Connect the
has_moreSelect block’s output to an If block’s variable input and renamevalue1tohas_more. -
Click Start writing TypeScript and enter “has_more”.
-
Connect the
body.dataSelect block’s output to the If block’s Data input.
-
Connect an Evaluate block’s variable input to the If block’s THEN output. Rename
value1tocontacts. -
Click Start writing TypeScript 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 a paginated request
-
Connect an HTTP Request block to the Evaluate block’s Result output.
-
Click Find or create new request and select Stripe API > Customers > List all customers pagination. The block automatically selects the Stripe + Brevo environment.
-
Next to the limit variable, click
Add data blocks and select Number. Enter “5” to specify how many contacts to include in each page of results.
-
Connect the Evaluate block’s Result output to the
starting_aftervariable in the HTTP Request block. -
Connect the HTTP Request block’s Success output to both the
body.has_nextand thebody.dataSelect blocks’ inputs.
Add a loop to send contacts to Brevo
-
Connect the If block’s THEN and ELSE outputs to a For block’s List input.
-
Connect the For block’s Item output to an HTTP Request block.
-
In the HTTP Request block, click Find or create new request and select Brevo API > Contact management > Contacts > POST Create a contact. Click Add environment and select Stripe + Brevo.
-
Connect the For block’s Item output to the
emailandfirst_namevariables’ inputs. Enter “name” for thefirst_namevariable and “email” for theemailvariable.
Run and verify the flow
Run the flow and confirm the records are added to Brevo.
