# Braze to Open Loyalty

## Outbound Updates: Modifying Open Loyalty Members

This guide explains how to automatically update member data in Open Loyalty based on user behavior in Braze. We achieve this by using **Braze Webhooks** to send API requests to Open Loyalty's Member API.

This is commonly used to:

* Add **Labels** to a member in Open Loyalty (e.g., "VIP", "Churn Risk").
* Update custom attributes based on Braze engagement.
* Sync segmentation status between platforms.

**Prerequisites**

<table><thead><tr><th width="197">Prerequisite</th><th>Description</th></tr></thead><tbody><tr><td><strong>API Token</strong></td><td>A permanent Open Loyalty token (<code>X-AUTH-TOKEN</code>) with permission to modify members.</td></tr><tr><td><strong>Tenant Code</strong></td><td>Your Open Loyalty Tenant Code.</td></tr><tr><td><strong>Matching IDs</strong></td><td>The user's <code>external_id</code> in Braze must match their <code>loyaltyCardNumber</code>  (or another default identifier - email, phone, member ID) in Open Loyalty.</td></tr></tbody></table>

***

### Integration Overview

This integration uses **Braze Webhooks** to send data *to* Open Loyalty. When a user enters a specific segment in Braze, we trigger a webhook that sends a `PATCH` request to the Open Loyalty Member API. This updates the member's **Labels** (custom attributes), which can then be used to define segments within Open Loyalty.

#### Prerequisites

| Prerequisite           | Description                                                                             |
| ---------------------- | --------------------------------------------------------------------------------------- |
| Open Loyalty API Token | A permanent token (`X-AUTH-TOKEN`) with permission to modify members.                   |
| Tenant ID              | Your Open Loyalty Tenant ID (e.g., `KHO`).                                              |
| Matching IDs           | The user's `external_id` in Braze must match their `loyaltyCardNumber` in Open Loyalty. |

***

## Setting up the integration

{% stepper %}
{% step %}

#### Define the Update Logic

Decide what triggers the update and what data you want to change. In this guide, we will add a **Label** (Custom Attribute) to a member profile.

* **Trigger:** A user enters a specific Segment in Braze (e.g., "High Spenders").
* **Action:** Add the label `braze_vip` to their Open Loyalty profile.
  {% endstep %}

{% step %}

#### Configure Braze Webhook Campaign

You can trigger this update via a **Webhook Campaign** or a **Webhook component** within a Braze Canvas.

1. In Braze, create a new **Webhook Campaign** (or use a Webhook within a Canvas).
2. Click on **Compose Webhook**
3. **Webhook URL:** Construct the URL using your Open Loyalty instance, Tenant ID, and the Braze Liquid variable for the user ID.&#x20;
   1. **Format: Sample format** `https://<YOUR_OL_INSTANCE>/api/<TENANT_ID>/member/loyaltyCardNumber={{${user_id}}}`&#x20;
   2. **Request Method:** `PATCH`&#x20;
   3. **Request Headers:**&#x20;
      * `Content-Type`: `application/json`
      * `X-AUTH-TOKEN`: `<YOUR_PERMANENT_TOKEN>`
      * `User-Agent: Braze`&#x20;
   4. **Request Body:** Select `Raw text` and paste the payload. You can customize the `key` and `value` to match your segment strategy.

```json
{
  "customer": {
    "labels": [
      {
        "key": "braze_vip_segment",
        "value": "optedIn"
      }
    ]
  }
}
```

{% endstep %}

{% step %}

#### Configure the Trigger

1. Navigate to the **Delivery** or **Entry Schedule** tab.
2. **Delivery Method**: Action-Based.
3. **Trigger**: Define Relevant Trigger
4. **Launch**: Activate the campaign.
   {% endstep %}

{% step %}

#### Testing the Setup

1. **Trigger the Webhook:** Manually add a test user to the target Braze segment or click "Send Test" in the webhook composer (you will need to supply a valid user ID).
2. **Verify in Braze:** Check the Message Activity Log to ensure the webhook returned a `200 OK` status.
   * *401 Error:* Checks your API Token.
   * *404 Error:* The user ID found in Braze does not exist in Open Loyalty.
3. Verify in Open Loyalty:
   * Log in to the Open Loyalty Admin Panel.
   * Navigate to Members > All Members and search for the test user.
   * Check the Labels or Custom Attributes section to confirm the new key-value pair exists.
   * Success: You should see the new label (e.g., `braze_brazeSegmentId: "optedIn"`).
   * *Optional:* If you created a Segment in Open Loyalty based on this label, confirm the user now appears in that segment.
     {% endstep %}
     {% endstepper %}
