# Brightpearl > Shopify - create/update companies, contacts & payment terms

## Introduction

This flow starts by retrieving contact details from Brightpearl. A script aggregates all contacts under their respective companies, designating a primary contact to populate the company's financial details. New companies are added to Shopify, and existing companies are updated.

## Process flow snapshot

<details>

<summary><img src="/files/y1IE71BfODU6ZRj1HNMM" alt="" data-size="line"> Click to view process flow snapshot</summary>

<figure><img src="/files/zpyVqwwk13SVxucaGRi5" alt=""><figcaption></figcaption></figure>

</details>

## Limitations

<table><thead><tr><th width="266.79296875">Limitation</th><th>Summary</th></tr></thead><tbody><tr><td>Identifying updated companies in Brightpearl</td><td>Brightpearl does not have the facility to search for 'updated' companies, so all companies are retrieved and searched in Shopify.</td></tr></tbody></table>

## Assumptions

<table><thead><tr><th width="266.79296875">Assumption</th><th>Summary</th></tr></thead><tbody><tr><td>Sync direction</td><td>Running this flow assumes that you want to sync data in this direction (i.e. from Brightpearl to Shopify). If required, a flow for the reverse direction is<a href="/pages/oSS9Hc95Izm25ZlTd4WB"> </a>available (<a href="/pages/rtlU1AF7gv2a3mG3bufT">Shopify > Brightpearl -  company and contact update/create</a>). You should run one or the other.</td></tr></tbody></table>

## Customisation

To ensure that this process flow runs as required, some customisation options are available. These are documented in the following sections:

* [Flow variables](#flow-variables)
* [Process shape shapes](#process-flow-shapes)

### Flow variables

This process flow does not use flow variables.

### Process flow shapes

This process flow includes some shapes that can be configured with your own settings. Please see guidelines in the table below.

{% hint style="warning" %}
Shape settings determine the outcome of process flows. Do not change shape settings unless they are listed below.&#x20;
{% endhint %}

<table data-full-width="false"><thead><tr><th width="220.09375">Shape</th><th>Notes</th></tr></thead><tbody><tr><td>Trigger</td><td>The default schedule for this flow is to run <code>daily at 05:00 PM</code>. This is the recommended run frequency but the schedule can be changed if necessary.</td></tr><tr><td>Connector (Brightpearl)</td><td>If you did not add or select a Brightpearl instance during the blueprint <a href="/pages/IUEvmNmJ8fj8u3vFE4Rn">installation process</a>, the following settings must be configured:<br><br><code>Source instance</code> : Set to your required <code>Brightpearl</code> instance.<br><code>Source endpoint</code> :  Set to <code>GET Get all contacts</code></td></tr><tr><td>Filter</td><td>Having retrieved all contacts from Brightpearl, this filter shape determines the lookback period for the updatedOn timestamp. The default setting is <code>-24 hours</code> - you can change this as required (keeping your trigger schedule in mind).</td></tr><tr><td>Connector (Shopify)<br>branch: <code>first branch</code> </td><td>If you did not add or select a Shopify instance during the blueprint <a href="/pages/IUEvmNmJ8fj8u3vFE4Rn">installation process</a>, the following settings must be configured:<br><br><code>Source instance</code> : Set to your required <code>Shopify</code> instance.<br><code>Source endpoint</code> :  Set to <code>POST Get all companies contacts and locations</code>   <br><code>Company name</code> : Set to <code>[[payload.name]]</code></td></tr><tr><td>Connector (Shopify)<br>branch: <code>first branch</code> </td><td>If you did not add or select a Shopify instance during the blueprint <a href="/pages/IUEvmNmJ8fj8u3vFE4Rn">installation process</a>, the following settings must be configured:<br><br><code>Source instance</code> : Set to your required <code>Shopify</code> instance.<br><code>Source endpoint</code> :  Set to <code>POST Add new contact to company</code></td></tr><tr><td>Connector (Shopify)<br>branch: <code>first branch</code> </td><td>If you did not add or select a Shopify instance during the blueprint <a href="/pages/IUEvmNmJ8fj8u3vFE4Rn">installation process</a>, the following settings must be configured:<br><br><code>Source instance</code> : Set to your required <code>Shopify</code> instance.<br><code>Source endpoint</code> :  Set to <code>POST Add new company location via graphql</code>  </td></tr><tr><td>Connector (Shopify)<br>branch: <code>first branch</code> </td><td>If you did not add or select a Shopify instance during the blueprint <a href="/pages/IUEvmNmJ8fj8u3vFE4Rn">installation process</a>, the following settings must be configured:<br><br><code>Source instance</code> : Set to your required <code>Shopify</code> instance.<br><code>Source endpoint</code> :  Set to <code>POST Get all locations of company</code>   <br><code>Company ID</code> : Set to  <code>[[payload.shopify_company_id.0.shopify_company_id]]</code> </td></tr><tr><td>Connector (Shopify)<br>branch: <code>first branch</code> </td><td>If you did not add or select a Shopify instance during the blueprint <a href="/pages/IUEvmNmJ8fj8u3vFE4Rn">installation process</a>, the following settings must be configured:<br><br><code>Source instance</code> : Set to your required <code>Shopify</code> instance.<br><code>Source endpoint</code> :  Set to <code>POST Update payment terms</code> </td></tr><tr><td>Connector (Shopify)<br>branch: <code>second branch</code> <br>➤ <code>new contact</code></td><td>If you did not add or select a Shopify instance during the blueprint <a href="/pages/IUEvmNmJ8fj8u3vFE4Rn">installation process</a>, the following settings must be configured:<br><br><code>Source instance</code> : Set to your required <code>Shopify</code> instance.<br><code>Source endpoint</code> :  Set to <code>POST Add new contact to company</code> </td></tr><tr><td>Connector (Shopify)<br>branch: <code>second branch</code> <br>➤ <code>new location</code></td><td>If you did not add or select a Shopify instance during the blueprint <a href="/pages/IUEvmNmJ8fj8u3vFE4Rn">installation process</a>, the following settings must be configured:<br><br><code>Source instance</code> : Set to your required <code>Shopify</code> instance.<br><code>Source endpoint</code> :  Set to <code>POST Add B2B company location via graphql</code>  </td></tr><tr><td>Connector (Shopify)<br>branch: <code>second branch</code> <br>➤ <code>update net terms</code></td><td>If you did not add or select a Shopify instance during the blueprint <a href="/pages/IUEvmNmJ8fj8u3vFE4Rn">installation process</a>, the following settings must be configured:<br><br><code>Source instance</code> : Set to your required <code>Shopify</code> instance.<br><code>Source endpoint</code> :  Set to <code>POST Update payment terms</code>  </td></tr></tbody></table>

## Reference

Reference information for this process flow is documented in the following sections:

* [Scripts used in this process flow](#scripts-in-this-process-flow)
* [Cross-reference lookups used in this process flow](#cross-reference-lookups-in-this-process-flow)

### Scripts in this process flow

<table><thead><tr><th width="293">Script</th><th>Summary</th></tr></thead><tbody><tr><td>Brightpearl - group companies</td><td>Groups Brightpearl companies for easier splitting.</td></tr><tr><td>BP to Shopify - Determine new or updated companies</td><td>Creates an array of Shopify addresses.</td></tr><tr><td>Inject company ID into multiple contacts</td><td>Structures a company contact correctly (for adding a new contact).</td></tr><tr><td>Brightpearl - inject company id when adding new location</td><td>Structures a company location correctly (for adding a new location).</td></tr><tr><td>Split locations for payment terms</td><td>Splits locations as needed for the creation of payment terms.</td></tr><tr><td>BP to Shopify - determine new contact and new locations to add</td><td>Creates arrays for new contacts and locations.</td></tr></tbody></table>

### Cross-reference lookups in this process flow

This process flow does not use cross-reference lookups.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.wearepatchworks.com/product-documentation/blueprints/patchworks-blueprints/shopify-and-brightpearl/available-process-flows-shopify-and-brightpearl/brightpearl-greater-than-shopify-create-update-companies-contacts-and-payment-terms.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
