> ## Documentation Index
> Fetch the complete documentation index at: https://docs.supercycle.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a workflow

> Build automations using Supercycle triggers and actions in Shopify Flow

This guide walks you through creating workflows in Shopify Flow using Supercycle triggers and actions. You'll learn how to build common automations and understand the workflow structure.

## Getting started

<Steps>
  <Step title="Open Shopify Flow">
    Navigate to <Icon icon="shopify" iconType="solid" /> [Shopify Flow](https://admin.shopify.com/apps/flow) in your Shopify admin and click **Create workflow**.
  </Step>

  <Step title="Choose a trigger">
    Search for **Supercycle** to see available triggers:

    * Return created / Return updated
    * Cycle created / Cycle updated / Cycle canceled
    * Membership created / Membership updated / Membership canceled
    * Charge failed
    * Payment collection failed
  </Step>

  <Step title="Add conditions and actions">
    Build your workflow logic using conditions, loops, and actions to respond to the trigger event.
  </Step>

  <Step title="Test and enable">
    Test your workflow with sample data, then enable it to start automating.
  </Step>
</Steps>

***

## Example workflows

### Pause subscription on return

Automatically pause a customer's subscription when they start a return.

<Frame type="glass" caption="Pausing subscriptions when returns are created">
  <iframe src="https://fast.wistia.net/embed/iframe/1kvx2zyjuz" title="Supercycle video" width="100%" height="400" allow="autoplay; fullscreen" frameborder="0" />
</Frame>

<Steps>
  <Step title="Add trigger">
    Select **Return created** as your trigger.
  </Step>

  <Step title="Add a loop">
    Add a **For each** loop and set it to `returnOrder.rentals`.\
    This processes each rental in the return individually.
  </Step>

  <Step title="Add a condition">
    Add a **Condition** to check if the rental has a subscription:

    ```
    rentals.foreachitem.subscriptionId is not empty and exists
    ```
  </Step>

  <Step title="Add the action">
    In the **Then** branch, add **Update subscription**:

    * **Subscription ID:** `{{rentals.foreachitem.subscriptionId}}`
    * **Status:** `paused`
  </Step>

  <Step title="Enable the workflow">
    Save and enable. Subscriptions will now pause automatically when returns are created.
  </Step>
</Steps>

***

### Send notification on failed payment

Notify your team when subscription payments fail multiple times.

<Steps>
  <Step title="Add trigger">
    Select **Payment collection failed** as your trigger.
  </Step>

  <Step title="Add a condition">
    Check if this is the third failed attempt:

    ```
    paymentCollector.failedPaymentCount is greater than or equal to 3
    ```
  </Step>

  <Step title="Add notification action">
    In the **Then** branch, add **Send internal email**:

    * **To:** Your support team email
    * **Subject:** `Urgent: Customer payment failed 3+ times`
    * **Body:** Include customer details and `paymentCollector.lastFailedPayment.errorMessage`
  </Step>

  <Step title="Optional: Cancel subscription">
    Add another action to **Update subscription**:

    * **Subscription ID:** Extract from `paymentCollector.subscriptionContractId`
    * **Status:** `cancelled`
  </Step>

  <Step title="Enable the workflow">
    Save and enable. Your team will be notified of payment issues automatically.
  </Step>
</Steps>

***

### Auto-resolve item conflicts on a cycle

When a cycle's allocated item is unavailable (for example, it's still out on another cycle), automatically re-allocate a fresh available item.

<Steps>
  <Step title="Add trigger">
    Select **Cycle updated** as your trigger.
  </Step>

  <Step title="Add a condition">
    Check whether the cycle has an item or variant conflict:

    ```
    rental.conflictLevel is equal to item or rental.conflictLevel is equal to variant
    ```
  </Step>

  <Step title="Add the action">
    In the **Then** branch, add **Re-allocate item**:

    * **Cycle ID:** `{{rental.id}}`
  </Step>

  <Step title="Enable the workflow">
    Save and enable. Cycles with item conflicts will be re-allocated automatically.
  </Step>
</Steps>

***

## FAQs

<AccordionGroup>
  <Accordion title="Can a single return include more than one rental?">
    Yes. Returns can contain multiple rentals, so always use a `For each loop` when processing `returnOrder.rentals` to ensure each rental is handled individually.
  </Accordion>

  <Accordion title="Do all rentals have a subscription attached?">
    No. Some rentals won’t have subscriptions, so you should always check whether subscriptionId exists before using it in any actions.
  </Accordion>

  <Accordion title="How should I validate my workflow before turning it on?">
    Use Shopify Flow’s test feature with sample data to confirm your logic works as expected before enabling it in production.
  </Accordion>

  <Accordion title="What’s the best way to name my workflows?">
    Use clear, descriptive names (for example, “Pause subscription on return”) so workflows are easy to find and manage later.
  </Accordion>

  <Accordion title="How do I make sure my workflows are running correctly over time?">
    Regularly monitor the Flow dashboard to confirm successful runs and catch or debug any errors early.
  </Accordion>
</AccordionGroup>
