Introduction
Welcome to the Chaay API. This API allows you to integrate loyalty rewards functionality into your applications, POS systems, and services.
Base URL
https://api.chaay.io/api
Request Format
All requests should be made with Content-Type: application/json header. Request bodies should be valid JSON.
Response Format
All responses are returned in JSON format with appropriate HTTP status codes.
// Successful Response
{
"success": true,
"data": { ... }
}
// Error Response
{
"success": false,
"error": {
"code": "INVALID_REQUEST",
"message": "Validation failed"
}
}
Authentication
The Chaay API uses JWT (JSON Web Tokens) for authentication. Include the token in the Authorization header:
Authorization: Bearer <your_jwt_token>
Authentication Types
| Type | Usage | Token Lifetime |
|---|---|---|
Customer JWT |
Customer mobile app | 7 days |
Merchant JWT |
Merchant dashboard & app | 24 hours |
API Key |
POS integration | No expiry |
Error Handling
The API uses standard HTTP status codes to indicate success or failure.
| Status Code | Description |
|---|---|
200 |
Success |
400 |
Bad Request - Invalid parameters |
401 |
Unauthorized - Invalid or missing token |
403 |
Forbidden - Insufficient permissions |
404 |
Not Found - Resource doesn't exist |
429 |
Too Many Requests - Rate limit exceeded |
500 |
Internal Server Error |
Send OTP
Send a one-time password to a customer's phone number for authentication.
Sends OTP via WhatsApp or SMS
Request Body
| Parameter | Type | Description |
|---|---|---|
phoneNumber |
string Required | Customer phone number with country code (e.g., +964771...) |
referralCode |
string Optional | Referral code if registering via referral |
Example
// Request
POST /api/auth/customer/send-otp
{
"phoneNumber": "+964 771 137 2822"
}
// Response
{
"success": true,
"message": "OTP sent successfully",
"expiresIn": 300
}
Verify OTP
Verify the OTP and receive authentication tokens.
Verifies OTP and returns JWT tokens
Request Body
| Parameter | Type | Description |
|---|---|---|
phoneNumber |
string Required | Customer phone number |
otp |
string Required | 6-digit OTP code |
Example
// Response
{
"accessToken": "eyJhbGciOiJIUzI1NiIs...",
"refreshToken": "dGhpcyBpcyBhIHJlZnJl...",
"expiresIn": 604800,
"isNewUser": false
}
Customer Profile
Get authenticated customer's profile
Response
{
"id": "uuid",
"phoneNumber": "+964 771 137 2822",
"name": "Ahmed Ali",
"email": "[email protected]",
"tier": {
"id": "uuid",
"name": "Gold",
"pointsMultiplier": 1.5
},
"pointsBalance": 2450,
"lifetimePoints": 5200,
"referralCode": "AHMED2024"
}
Wallet & Points
Get current point balance
Get transaction history (paginated)
Query Parameters
| Parameter | Type | Description |
|---|---|---|
limit |
integer | Number of results (default: 20, max: 100) |
offset |
integer | Pagination offset (default: 0) |
type |
string | Filter by type: earn, redeem, bonus, adjustment |
Vouchers
List available vouchers to claim
Claim a voucher using points
Get customer's claimed vouchers
Referrals
Get or generate referral code
Get referral statistics
Response
{
"referralCode": "AHMED2024",
"totalReferrals": 12,
"monthlyReferrals": 3,
"pointsEarned": 600
}
Badges
List all badges the customer has earned, grouped by rarity (Common, Rare, Epic, Legendary, Mythic).
Response
{
"earned": [
{
"id": "uuid",
"code": "first_visit",
"name": "First Visit",
"rarity": "common",
"iconUrl": "https://cdn.chaay.io/badges/first-visit.svg",
"earnedAt": "2026-04-10T14:22:00Z"
}
],
"totalEarned": 7,
"totalAvailable": 10
}
Challenges
List active challenges with progress for the authenticated customer.
Opt-in to a challenge that requires manual enrollment.
Streaks
Get current streaks, longest streak, and available freeze tokens.
Consume one freeze token to protect a streak from breaking.
Leaderboards
Get the customer's current rank across all active leaderboards (weekly spend, visit count, referrals, etc.).
Response
{
"leaderboards": [
{
"id": "uuid",
"code": "weekly_spend",
"name": "Weekly Spend",
"rank": 4,
"score": 128500,
"totalParticipants": 1842,
"resetsAt": "2026-04-28T00:00:00Z"
}
]
}
Merchant Dashboard
Get merchant dashboard statistics
Response
{
"totalCustomers": 2847,
"activeCustomers": 1523,
"pointsAwarded": 45200,
"pointsPool": 10000,
"vouchersRedeemed": 234,
"returnRate": 0.89
}
Award Points
Award points to a customer
Request Body
| Parameter | Type | Description |
|---|---|---|
customerId |
string Required | Customer UUID or phone number |
amount |
number Required | Purchase amount for point calculation |
invoiceNumber |
string Optional | Reference invoice number |
Merchant Vouchers
Create a new voucher
List merchant's vouchers
Redeem customer's voucher
POS: Verify Customer
Verify a customer by phone number or QR code scan.
Verify customer identity
Headers
X-API-Key: your_merchant_api_key
Query Parameters
| Parameter | Type | Description |
|---|---|---|
phone |
string | Customer phone number |
qrCode |
string | QR code value from customer app |
POS: Award Points
Award points via POS system
Request Body
{
"customerId": "uuid-or-phone",
"purchaseAmount": 25.50,
"invoiceNumber": "INV-001234",
"timestamp": "2026-01-24T10:30:00Z"
}
POS: Redeem Voucher
Redeem customer voucher via POS
Request Body
{
"voucherCode": "VCHR-ABC123",
"customerId": "uuid"
}
Response
{
"success": true,
"voucher": {
"name": "Free Tea",
"discountType": "percentage",
"discountValue": 100
},
"redeemedAt": "2026-01-24T10:35:00Z"
}