Shopify Flow + Orders API

Using Shopify Flow to trigger the Orders API

When to use Shopify Flow + Orders API

If Shopify is your source of truth for revenue data, our default recommendation is to use the Northbeam Shopify App to automatically sync Shopify orders data with Northbeam.

If you intend to implement a multi-dashboard configuration in Northbeam using data from a single Shopify instance, you may need to apply logic to conditionally send orders to different Northbeam instances. This guide describes how to send Shopify orders to Northbeam using our Orders API via Shopify Flow.

How to build a Shopify Flow for Northbeam Orders

  1. Install the Shopify Flow app in your Shopify Account.
  1. Click Create Flow
  2. Choose Select a Trigger
  3. Trigger on the Order created event
  4. On the Order created event, click Then (+) to add a next step
  1. Add Send HTTP request as the next step
  1. Configure the request
    1. HTTP method: POST
    2. URL: https://api.northbeam.io/v2/orders
    3. Headers:
      1. Authorization: (your API key)
      2. Data-Client-ID: (your Data-Client-ID)
      3. Content-Type: application/json
    4. body:
[
  {
    "products": [
      {% for lineItems_item in order.lineItems %}
        {
          "id": "{{lineItems_item.id | remove: 'gid://shopify/LineItem/'}}",
          "name": "{{lineItems_item.name | replace: '"', '' }}",
          "quantity": {{lineItems_item.quantity}},
          "price": {{lineItems_item.originalTotalSet.shopMoney.amount}}
        }{% unless forloop.last %},{% endunless %}
      {% endfor %}
    ],
    "order_id": "{{order.id | remove: 'gid://shopify/Order/'}}",
    "customer_id": "{% if order.customer.id == '' %}{{order.customer.email}}{% else %}{{order.customer.id | remove: 'gid://shopify/Customer/'}}{% endif %}",
    "time_of_purchase": "{{order.createdAt}}",
    "tax": {{order.totalTaxSet.shopMoney.amount}},
    "currency": "{{order.currencyCode}}",
    "purchase_total": {{order.totalPriceSet.shopMoney.amount}},
    "shipping_cost": {{order.totalShippingPriceSet.shopMoney.amount}},
    "order_tags": [
      {% for tags_item in order.tags %}
        "{{tags_item}}"{% unless forloop.last %},{% endunless %}
      {% endfor %}
    ]
  }
]

🚧

Note

  • This example maps to the default Shopify fields. You may need to customize the variables for your instance.
  • This body will return errors if the Shopify lineItems array is empty. products is a required field of the Orders API.

📘

API Key and Data-Client-ID

Get your API Key and Data-Client-ID here

Testing? Use:

  • Authorization: None
  • Data-Client-ID: test
  • Content-Type: application/json
  1. Click the Apply changes button in the top right of the page
  2. In the modal, click Apply
  3. Exit the editor and trigger the workflow to test that the workflow successfully runs
    1. You can find the log in Recent runs
    2. Having trouble? Reach out to our team for help.

Customizing for your configuration

This guide covers the first and final steps of using Shopify Flow and the Orders API to send data to Northbeam. The workflow above sends every order to the same Northbeam dashboard. In order to use this for your use-case, you'll need to customize intermediate steps to conditionally sort orders to map to different Northbeam dashboards.

Examples:

Split US and International Orders

To send US and International orders data to different dashboards, add a Condition to check if the customer address country is equal to the United States. If true, then trigger the Orders API for the US dashboard. Otherwise, trigger the Orders API for the International dashboard.