# Data Sync

The sync works by linking your loyalty platform (Yotpo or Clearer.io) with Apparel21 (POS) through the DotApparel API. This integration lets Apparel21 use the platform's complete loyalty features, replacing the old Rewards module in Apparel21.

## New Loyalty Sign-Ups

* **New Customers from POS:** Customers can join the loyalty program when they're at the store. New customers from Apparel21 sync through to Yotpo Loyalty via DotApparel API. To make sure that new customers signing up for loyalty programs in stores experience minimal delays, we've set up a process to sync the updated customer data **every minute**. DotApparel Loyalty will create the customer in the connected Shopify store. This step ensures that customer data is centralised and synchronised across Apparel21, Shopify and Yotpo.
* **New Customers from Online:** The loyalty platform's Shopify integration will automatically sync the newly created Shopify customer to the loyalty program. Information automatically gets associated to the respective customer profile. This means customers can start earning and using their rewards both in the store and online.

{% hint style="info" %}
**In-store customers must be marked as `WEB` customers in Apparel21**

To make sure the loyalty system can work with in-store customers, it's really important to label them as `WEB` in Apparel21. This labelling helps the loyalty system connect with them and make updates through the API.
{% endhint %}

## Loyalty Tiers

We're connecting your loyalty platform with Apparel21 to combine loyalty data, like tier names, expiry dates and rewards. This gives a full picture of customers' loyalty everywhere and allows personalised service based on their achievements. Here's how we do it:

* **Setting Up a Listener:** We create a special "listener" in DotApparel Loyalty that waits for a signal from your loyalty platform whenever a customer's loyalty tier changes.
* **Getting the Update:** The loyalty platform tells us a customer's tier changed, who they are and the tier expiry dates.
* **Updating in Apparel21:** We then use the DotApparel API to tell Apparel21 to update that customer's tier level.
* **Customising in Apparel21:** We decide how the loyalty info should look in Apparel21, which might mean tweaking some fields or attributes in the AP21 person record to store loyalty-related information.

{% hint style="info" %}
**Apparel21 Customer Attributes**

Keep in mind that customising Apparel21 might come with specific rules and limitations. Before project kick-off we need to decide how the loyalty info should appear in Apparel21 and POS.
{% endhint %}

## In-store Purchases

We're connecting the in-store order data in Apparel21 with Yotpo's loyalty program. This way, when customers shop in the store, they'll still get rewards as all of the information lands back into Yotpo Loyalty. Here's how we do it:

* **Exporting Store Purchase Data:** The app grabs all the info about customers' in-store purchases from POS. This data is usually in a file that looks like a spreadsheet and includes details about your order, who you are, and what you bought. More info here.
* **Saving the Store Data:** The app keeps this data in our system so we can work with it. It's like putting it on our shelf for later. The saved data is processed at the desired interval, which is daily or hourly.
* **Sending Data to the Loyalty Platform:** We use the loyalty platform's API to send customers' in-store purchase data through. It's a bit like mailing a letter. Specifically, the platform's "Create Order" endpoint is used for this purpose. The app constructs the necessary request payload using the stored in-store order data and sends it through.
* **Making the Data Fit:** Before sending it, we make sure the data looks right for the loyalty platform's system. It's a bit like translating it into a language the platform understands. All the mappings and transformations to ensure compatibility with the platform's API format are visible in the DotApparel Loyalty app interface.
* **Getting Your Loyalty Status:** The loyalty platform receives the data, figures out the tier the customer should belong to based on the loyalty rules, and then assigns the correct tier status to the customer's account. This means customers get rewards for their in-store shopping (not just online).<br>


---

# 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://docs.dotapparel.com.au/loyalty/data-sync.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.
