Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/AndrewwCO/Panahashi-Backend/llms.txt

Use this file to discover all available pages before exploring further.

The Loyalty API manages per-bakery stamp cards for customers. Each customer gets a separate card for every bakery they order from. Stamps are added automatically when an order reaches COMPLETED status. Every 9 stamps earns one free item, which a baker can redeem.

LoyaltyCard object

id
string
Card ID — formatted as {userId}_{bakeryId}.
userId
string
Card owner’s Firebase UID.
bakeryId
string
Bakery this card belongs to.
stamps
integer
Current stamp count (0–8 before reward).
stampsForReward
integer
Stamps required for one reward. Always 9.
totalRewardsEarned
integer
Lifetime rewards earned.
freeItemsAvailable
integer
Unclaimed free items available to redeem.
updatedAt
integer
Last updated epoch ms.

GET /api/v1/loyalty

Returns all loyalty cards for the authenticated customer across all bakeries. Auth required: Yes — CUSTOMER
curl -H "Authorization: Bearer <token>" \
  http://localhost:8080/api/v1/loyalty

GET /api/v1/loyalty/

Returns the customer’s loyalty card for a specific bakery. Creates the card if it doesn’t exist yet. Auth required: Yes — CUSTOMER
bakeryId
string
required
Bakery ID.
curl -H "Authorization: Bearer <token>" \
  http://localhost:8080/api/v1/loyalty/bak001
Response:
{
  "success": true,
  "data": {
    "id": "uid123_bak001",
    "stamps": 4,
    "stampsForReward": 9,
    "freeItemsAvailable": 0,
    "totalRewardsEarned": 1
  }
}

POST /api/v1/loyalty/redeem

Redeems one free item from a customer’s loyalty card for the baker’s bakery. Auth required: Yes — BAKER
userId
string
required
Firebase UID of the customer whose reward to redeem.
curl -X POST \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"userId":"uid123"}' \
  http://localhost:8080/api/v1/loyalty/redeem
Returns 400 if the customer has no free items available (freeItemsAvailable = 0).

How stamps are earned

Stamps are added automatically — you don’t need to call any endpoint. When a baker marks an order as COMPLETED (or verifies the QR), the system:
  1. Adds one stamp to the customer’s card for that bakery.
  2. If stamps reach a multiple of 9, increments freeItemsAvailable by 1 and totalRewardsEarned by 1.
  3. Sends the customer a push notification announcing their stamp progress.

Build docs developers (and LLMs) love