Documentation Index
Fetch the complete documentation index at: https://docs.foodsave.kz/llms.txt
Use this file to discover all available pages before exploring further.
Loyalty API
Base path: /api/v1/loyalty
Overview
Loyalty endpoints expose score, referral and promo-code workflows.
The score endpoint is read-only, while referral and promo application mutate user state and should be retried carefully.
GET /api/v1/loyalty/score
Return the current user’s score.
{ "userId":"u-1", "points": 340, "level":"Silver", "foodSavedGrams": 1250, "ordersCompleted": 19, "referralCode":"SAVE-ABCD" }
POST /api/v1/loyalty/referral
Attach a referral code.
curl --request POST \
--url https://api.foodsave.kz/api/v1/loyalty/referral \
-H 'Authorization: Bearer $CUSTOMER_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"referralCode":"SAVE-ABCD"}'
const response = await fetch('https://api.foodsave.kz/api/v1/loyalty/referral', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.CUSTOMER_TOKEN}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ referralCode: 'SAVE-ABCD' })
})
console.log(await response.json())
import os
import requests
response = requests.post(
'https://api.foodsave.kz/api/v1/loyalty/referral',
headers={'Authorization': f"Bearer {os.environ['CUSTOMER_TOKEN']}"},
json={'referralCode': 'SAVE-ABCD'}
)
print(response.json())
{ "userId":"u-1", "points": 340, "level":"Silver" }
POST /api/v1/loyalty/promo/apply
Validate a promo code and compute discount.
{ "valid": true, "discountCents": 500, "error": null }
Promo validation does not reserve inventory or lock pricing; apply the promo only after order re-check.
Errors
| Code | Meaning | How to fix |
|---|
| 400 | INVALID_PROMO | Check code and minimum order amount |
POST /api/v1/admin/promo/create
Create a promo code.
{ "id":"promo-1", "code":"WELCOME10", "active":true }
Enable or disable a promo.
{ "id":"promo-1", "active":false }