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

# Redeem Through Your Couponing Engine

> If you already have a backend couponing system, whether custom-built or part of your e-commerce platform, Gameball allows you to plug into it via webhooks. This lets Gameball notify your system to create a coupon when a customer earns or redeems a reward. You keep full control over coupon creation logic, while Gameball handles loyalty tracking, redemption rules, and reward delivery. 

## **What Does This Integration Do?**

Instead of using Gameball’s native coupon engine, Gameball can send a **real-time HTTP request** to your system when:

* A customer **redeems points** for a coupon reward
* A customer **completes a campaign** and earns a coupon

Your system then returns a valid coupon code, which Gameball shows to the customer.

<Frame>
  <img src="https://mintcdn.com/gameball/tbHJ33JKkFfY2kVp/images/your_engine.png?fit=max&auto=format&n=tbHJ33JKkFfY2kVp&q=85&s=c0ffc9a7a0c6eff67c0eec454d72f801" width="1034" height="444" data-path="images/your_engine.png" />
</Frame>

## **Supported Use Cases**

| **Scenario**    | **Example**                                         |
| :-------------- | :-------------------------------------------------- |
| Redeem Points   | Adam redeems 500 points and receives a 10% OFF code |
| Campaign Reward | Sarah completes a mission and earns a \$20 coupon   |

## **Flow: How Gameball Communicates With Your System**

<Steps>
  <Step title="Customer initiates a redemption (or completes a campaign)" />

  <Step title="Gameball sends a POST request to your specified endpoint" />

  <Step title="Your system generates the coupon and returns the code" />

  <Step title="Gameball shows the code to the user in their profile or reward message" />

  <Step title="Customer copies/pastes the code at checkout on your store" />
</Steps>

# Implementation Guide

## Step-by-Step Integration Flow

### Step 1: Configure Gameball to Call Your Endpoint

| **Gameball Widget**                                                | **Custom UI**                                                                    |
| :----------------------------------------------------------------- | :------------------------------------------------------------------------------- |
| Configuration required only once — the rest is handled internally. | Same configuration required — you control how the coupon is generated/displayed. |

Gameball needs to know how to reach your couponing engine:

<Frame>
  <img src="https://mintcdn.com/gameball/tbHJ33JKkFfY2kVp/images/coupon-configurations.png?fit=max&auto=format&n=tbHJ33JKkFfY2kVp&q=85&s=da29bcdede2d6df6281891fa6ef93682" width="1726" height="1116" data-path="images/coupon-configurations.png" />
</Frame>

| **Field**     | **Description**                                                                                                       |
| :------------ | :-------------------------------------------------------------------------------------------------------------------- |
| url           | Your coupon generation endpoint, e.g., [https://api.yourapp.com/create-coupon](https://api.yourapp.com/create-coupon) |
| method        | Usually POST                                                                                                          |
| contentType   | Typically application/json                                                                                            |
| headers       | Auth or token headers, if needed                                                                                      |
| payload       | The request body Gameball will send                                                                                   |
| couponMapping | Map Gameball coupon types to your supported types                                                                     |
| platforms     | Platforms where the coupon applies (e.g., web, mobile, POS)                                                           |

### **Step 2: Configure via API (Optional)**

You can configure this directly via API:

**API:**

PUT /api/v4.0/integrations/configurations/coupon

APIKey: YOUR\_API\_KEY

SecretKey: YOUR\_SECRET\_KEY

Content-Type: application/json

```json theme={null}
{
  "url": "https://yourdomain.com/api/coupons",
  "method": "POST",
  "contentType": "application/json",
  "headers": [
    { "key": "Authorization", "value": "Bearer 123456" }
  ],
  "payload": {
    "code": "{{code}}",
    "value": "{{amount}}",
    "couponType": "{{discount_type}}"
  },
  "couponMapping": {
    "percentage": true,
    "fixed": true,
    "freeShipping": true
  },
  "platforms": ["web", "mobile"]
}
```

### **Step 3: Build Your Coupon Creation Endpoint**

This is your own API that Gameball will call.

**Example (Node.js):**

```javascript theme={null}
app.post('/api/coupons', (req, res) => {
  const { code, value, customerId } = req.body;
  // Create and store the coupon
  res.status(200).send({ couponCode: code });
});
```

<Note>
  You must return HTTP 200 and include the coupon code in the response.
</Note>

### **Step 4: Test the Connection**

| **Gameball Widget**                                                            | **Custom UI**                                      |
| :----------------------------------------------------------------------------- | :------------------------------------------------- |
| Use **“Test Connection”** from Gameball dashboard to simulate coupon creation. | Same. Useful for debugging or dry-run integration. |

**API (to retrieve config):**

GET /api/v4.0/integrations/configurations/coupon

APIKey: YOUR\_API\_KEY

SecretKey: YOUR\_SECRET\_KEY

***

# Coupon Redemption Flows

Gameball supports two primary coupon generation flows, both of which work with either the **Gameball widget** or your **custom UI**.

## **1. Manual Coupon Redemption**

### **Overview**

| **Gameball Widget**                                                                     | **Custom UI**                                                             |
| :-------------------------------------------------------------------------------------- | :------------------------------------------------------------------------ |
| Redemption flow is fully handled: point display, coupon generation, and coupon listing. | You handle reward options, redemption calls, and coupon display manually. |

### **Step-by-Step: Widget-Based Manual Redemption**

**Step 1:**

Customer opens the widget → Gameball displays points balance and redemption options.

<img src="https://mintcdn.com/gameball/tbHJ33JKkFfY2kVp/images/widget.png?fit=max&auto=format&n=tbHJ33JKkFfY2kVp&q=85&s=4671e15f411d754b6aaf1566745ca812" alt="image (121).png" title="image (121).png" className="mx-auto" style={{ width:"32%" }} width="676" height="1262" data-path="images/widget.png" />

**Step 2:**

Customer selects a reward → Gameball sends a webhook to your backend and shows the returned coupon in **My Coupons**.

<img src="https://mintcdn.com/gameball/tbHJ33JKkFfY2kVp/images/redemptionthroughwidget-ezgif.com-video-to-gif-converter.gif?s=53649a5821191333fb580b33c63a20a6" alt="Redemptionthroughwidget Ezgif Com Video To Gif Converter Gi" title="Redemptionthroughwidget Ezgif Com Video To Gif Converter Gi" className="mx-auto" style={{ width:"31%" }} width="722" height="1304" data-path="images/redemptionthroughwidget-ezgif.com-video-to-gif-converter.gif" />

**Step 3:**

At checkout, the customer applies the coupon. You use:

<img src="https://mintcdn.com/gameball/tbHJ33JKkFfY2kVp/images/couponredemption-ezgif.com-video-to-gif-converter.gif?s=556cff6c61f9d36653fe0677f10ca40a" alt="Couponredemption Ezgif Com Video To Gif Converter Gi" title="Couponredemption Ezgif Com Video To Gif Converter Gi" className="mx-auto" style={{ width:"32%" }} width="800" height="1178" data-path="images/couponredemption-ezgif.com-video-to-gif-converter.gif" />

```http theme={null}
POST /order
```

```json filename="request.json" theme={null}
{
  "customerId": "cust_12345",
  "orderId": "ORD123",
  "totalPaid": 135,
  "coupons": {
    "couponCodes": ["GB1023"]
  }
}
```

***

### **Step-by-Step: Custom UI Manual Redemption**

**Step 1: Fetch Redemption Options**

[GET /redemption-configs](/api-reference/configurations/reward-configurations/redemption-settings)

```json filename="response.json" theme={null}
{
  "redemptionRules": [
    {
      "id": 2138,
      "pointsToRedeem": 100,
      "coupon": {
        "couponType": "fixed_rate_discount",
        "discountValue": 10
      }
    }
  ]
}
```

**Step 2: Redeem Points**

[POST /redeem](/api-reference/transactions/cashback-and-redemptions/redeem#redeem-points)

```json filename="request.json" theme={null}
{
  "customerId": "cust_12345",
  "ruleId": 2138,
  "transactionId": "txn_001",
  "transactionTime": "2024-11-01T12:00:00Z"
}
```

```json filename="response.json" theme={null}
{
  "couponCode": "GB1023",
  "redeemEquivalentPoints": 100
}
```

**Step 3: Display Earned Coupons**

[GET /customers//coupons](/api-reference/customers/management/get-customer-coupons)

**Step 4: Apply at Checkout**

Same as widget, use the [POST /order API](/api-reference/order/order-tracking).

<img src="https://mintcdn.com/gameball/tbHJ33JKkFfY2kVp/images/couponredemption-ezgif.com-video-to-gif-converter.gif?s=556cff6c61f9d36653fe0677f10ca40a" alt="Couponredemption Ezgif Com Video To Gif Converter Gi" title="Couponredemption Ezgif Com Video To Gif Converter Gi" className="mx-auto" style={{ width:"44%" }} width="800" height="1178" data-path="images/couponredemption-ezgif.com-video-to-gif-converter.gif" />

## **2. Campaign-Based Coupon Rewards**

<Tabs>
  <Tab title="Gameball Widget">
    Widget automatically shows campaign-earned coupons in “My Coupons”.

    <img src="https://mintcdn.com/gameball/tbHJ33JKkFfY2kVp/images/redeem.png?fit=max&auto=format&n=tbHJ33JKkFfY2kVp&q=85&s=2b1099bde1940682d750be31c4187383" alt="image (122).png" title="image (122).png" className="mx-auto" style={{ width:"26%" }} width="452" height="830" data-path="images/redeem.png" />

    ### **Step-by-Step: Widget Campaign Flow**

    * Gameball displays the coupon in real-time once earned from a campaign.
    * No API integration needed to show it.
    * At checkout, use [POST /order](/api-reference/order/order-tracking) as shown earlier.
  </Tab>

  <Tab title="Custom UI">
    You must fetch and display earned coupons using the API.

    <Frame>
      <img src="https://mintcdn.com/gameball/tbHJ33JKkFfY2kVp/images/redeem-ui.png?fit=max&auto=format&n=tbHJ33JKkFfY2kVp&q=85&s=43bd22942a17882aa7562ea5bc722b59" width="978" height="340" data-path="images/redeem-ui.png" />
    </Frame>

    ### **Step-by-Step: Custom UI Campaign Flow**

    **Step 1: Fetch All Coupons**

    [GET /customers/{playerId}/coupons](/api-reference/customers/management/get-customer-coupons)

    ```json theme={null}
    {
      "coupons": [
        {
          "code": "GB2024",
          "type": "percentage_discount",
          "value": 15,
          "expiryDate": "2024-12-31T23:59:59Z"
        }
      ]
    }
    ```

    **Step 2: Apply Coupon**

    [POST /order](/api-reference/order/order-tracking)

    ***

    ## **Final Summary**

    | **Step**                        | **Widget**            | **Custom UI**                   |
    | :------------------------------ | :-------------------- | :------------------------------ |
    | Configure Webhook               | ✅ Required            | ✅ Required                      |
    | Show redemption options         | ✅ Auto                | ✅ Manual                        |
    | Redeem points → generate coupon | ✅ Auto                | ✅ API (/redeem)                 |
    | Show earned coupons             | ✅ Auto (“My Coupons”) | ✅ API (/customers/{id}/coupons) |
    | Apply at checkout               | ❌ (manual)            | ❌ (manual)                      |
  </Tab>
</Tabs>

***

## Related Resources

<CardGroup cols={2}>
  <Card title="Redeem Points API" icon="coins" href="/api-reference/transactions/cashback-and-redemptions/redeem#redeem-points">
    Convert loyalty points into coupon rewards
  </Card>

  <Card title="Generate Coupon API" icon="ticket" href="/api-reference/coupons/generate-coupon">
    Use Gameball’s engine when you don’t need custom issuance
  </Card>

  <Card title="Get Customer Coupons API" icon="list" href="/api-reference/customers/management/get-customer-coupons">
    Display coupons created by your backend
  </Card>

  <Card title="Gameball Coupon Engine Tutorial" icon="sparkles" href="/tutorials/experiences/points-redemption/convert-points-to-coupons/gameball-engine">
    Learn the built-in alternative to custom coupon generation
  </Card>
</CardGroup>
