Loyalty
View and manage customer loyalty points. Points are automatically awarded when orders are created (1 point per currency unit spent).
Automatic point earning Points are automatically awarded on order creation. You only need this endpoint to check balances or manually redeem points.
Endpoints
GET/loyalty/:customer_idGet loyalty balance
GET/loyalty/:customer_id/historyPoint transaction history
POST/loyalty/redeemRedeem points
Get balance - GET /loyalty/:customer_id
Returns the current loyalty point balance and lifetime statistics for a customer.
curl "https://qatxonlxvtgxvqjgfxpl.supabase.co/functions/v1/api/loyalty/7d2e1f09-..." \
-H "Authorization: Bearer do_live_YOUR_KEY"const balance = await client.loyalty.getBalance('7d2e1f09-...')balance = client.loyalty.get_balance('7d2e1f09-...')Response
{
"customer_id": "7d2e1f09-...",
"balance": 1450,
"lifetime_earned": 2800,
"lifetime_redeemed": 1350
}
Point history - GET /loyalty/:customer_id/history
Returns a list of all point transactions for the customer, ordered by most recent first.
[
{
"id": "txn-uuid",
"type": "earn",
"points": 202,
"sale_id": "9f3a8c12-...",
"description": "Order S-0042",
"created_at": "2026-06-02T14:30:00.000Z"
},
{
"id": "txn-uuid-2",
"type": "redeem",
"points": -500,
"sale_id": null,
"description": "Redeemed for store credit",
"created_at": "2026-05-20T10:15:00.000Z"
}
]
Redeem points - POST /loyalty/redeem
Manually redeem loyalty points for a customer. The customer must have sufficient balance.
| Field | Type | Required | Description |
|---|---|---|---|
| customer_id | UUID | required | Customer UUID |
| points | Number | required | Points to redeem |
| reason | String | optional | Description of what they're redeemed for |
POST /loyalty/redeem
{
"customer_id": "7d2e1f09-...",
"points": 500,
"reason": "Redeemed for store credit"
}
Response
{
"success": true,
"data": {
"transaction_id": "txn-new-uuid",
"customer_id": "7d2e1f09-...",
"points_redeemed": 500,
"new_balance": 950
}
}