Automate repetitive tasks using Postman Flows

You can use Postman Flows to complete repetitive tasks. Businesses often need to delete emails from multiple systems. Logging in, searching, and deleting emails from multiple locations can be time consuming. This tutorial shows you how to create a Flow that deletes an email from three locations each time you run the Flow.

For this tutorial, the locations are Stripe.com, Brevo.com, and a Postman mock server that acts as a hypothetical internal system.

You can find the complete Flow here.

Prerequisites

  • A Stripe account with a customer with the test@email.com email address.
  • A Brevo account with a contact with the test@email.com email address.
  • A Stripe secret key.
  • A Brevo API key.

Fork the collections and environment

Fork these collections from the [DevOps Flows] workspace into your workspace:

Fork this environment into your workspace:

  • gdpr-delete-email

  • In the gdpr-delete-email environment, replace <your-brevo-api-key> with your Brevo API key. Replace <your-stripe-secret-key> with your Stripe secret key.

    Add API keys

Create the Flow

  1. Part one: Delete the contact from Stripe

    • Create a new Flow. Add a String block and enter test@email.com.

    • Connect a Create Variable block and enter Customer Email.

      Create a variable
    • Connect three Send Request blocks to the Start block, arranged vertically.

      Create three Send Request blocks
    • In the top Send Request block, select Stripe API > Customers > Search customers.

    • Select the gdpr-delete-email environment.

    • For the email variable, add a Get Variable block and select Customer Email.

      Get the variable
    • Create an If block next to the Send Request block. Add a Select block to the If block and change value1 to contacts.

      Add an If block
    • Connect the Send Request block’s Success output to the If block’s contacts and Data inputs. Next to contacts, select body.data. In the FQL window, enter $count(contacts) > 0.

    • Connect the If block’s FALSE output to an Output block.

    • Rename the Output block Contact not found and select Boolean from the dropdown list.

    • Connect the If block's TRUE output to a Send Request block. Select Stripe API > Customers > Delete a customer.

    • Also connect the If block’s TRUE output to the Send Request block’s customer_id input and select body.data.0.id.

    • Connect the Send Request block’s Success output to an Output block.

    • Rename the Output block Contact deleted and select Boolean from the dropdown list.

      Stripe contact deleted
  2. Part two: Delete the contact from Brevo

    • In the middle Send Request block, select Brevo > Contact management > Contacts > Get a contact’s details.

    • Select the gdpr-delete-email environment

    • For the email variable, add a Get Variable block and select Customer Email.

    • Connect this block’s Success output to another Send Request block and select Brevo > Contact management > Contacts > Delete a contact. Also connect the middle Send Request block’s Success output to the new Send Request block’s contact_id input and select body.id.

      Add Brevo requests
    • Connect the Delete a contact block’s Success output to an Output block. Rename the Output block Contact deleted and select Boolean from the dropdown list.

    • Connect an Output block to the Get a contact’s details Send Request block’s Failure output. Rename the Output block Contact not found and select Boolean from the dropdown list.

      Brevo contact deleted
  3. Part three: Delete the contact from an internal system

    • In the bottom Send Request block, select customer-list > customer/email.

    • For the email variable, add a Get Variable block and select Customer Email.

    • Connect the Success output to a Send Request block and select customer-list > customer/id.

    • Also connect the customer/email Send Request block’s Success output to the id input and select body.id.

    • Connect the customer/id Send Request block’s Success output to an Output block. Rename the Output block Contact deleted and select Boolean from the dropdown list.

    • Connect the customer/id Send Request block’s Failure output to an Output block. Rename the Output block Contact not found and select Boolean from the dropdown list.

      Internal contact deleted

Run the Flow

Select Run. The Flow finds and deletes the contact with the test@email.com email address on Brevo, Stripe, and the internal system. When the contact is deleted, the Contact deleted Output block shows True. If there is no contact with that email address, the Contact not found Output block shows False.

Last modified: 2023/07/27