# DigiRewardCard Partner & POS API Documentation
Welcome to the DigiRewardCard Partner API. This API allows your existing Point of Sale (POS), CRM, or e-commerce systems to seamlessly integrate with your PulaPartners loyalty program.
> **Commodity Price Privacy Guarantee:** PulaPartners **never** requires, receives, or records the prices of your store's commodities or bill totals. Each store configures its own **Point-to-Pula equivalence rate** (Recommended default: **`1 point = P0.20`**, or any rate at your store's discretion such as `1 point = P0.50`). When your POS deducts points at checkout, PulaPartners calculates and returns only the **points adjusted** and their **Pula monetary equivalent** so your POS can subtract that discount directly from the customer's bill.
---
## Authentication
All requests to the Partner API must be authenticated using an API Key. You can generate API Keys from your PulaPartners Dashboard under the **"API Integrations"** tab.
Include the API Key in your requests using the `Authorization` header:
```http
Authorization: Bearer drk_your_api_key_here
```
*(Alternatively, you can use the `X-API-Key: drk_your_api_key_here` header).*
---
## 1. Scan & Lookup a Loyalty Card or Promo Code at the POS
**Endpoints:**
- `GET /api/store/pos/lookup/:code`
- `POST /api/store/pos/lookup` (Body: `{ "code": "DRK-DANGER-001" }`)
When the cashier scans a customer's digital card (`DRK-...`) or 8-digit promo code at the till, call this endpoint to immediately retrieve the customer's available points, your store's Point-to-Pula rate, and the maximum Pula discount equivalent available on their card.
#### cURL Example
```bash
curl -X GET https://api.digirewardcard.com/api/store/pos/lookup/DRK-DANGER-001 \
-H "Authorization: Bearer drk_123456789"
```
#### Response Example
```json
{
"type": "loyalty_card",
"cardId": 1,
"cardNumber": "DRK-DANGER-001",
"cardholderName": "Neo Molefe",
"tier": "Silver",
"points": 120,
"pointValuePula": 0.2,
"availableDiscountPula": 24.0,
"rateLabel": "1 point = P0.20"
}
```
---
## 2. Redeem (or Add) Points at the POS by Scanned Card Number
**Endpoint:** `POST /api/store/pos/redeem`
Deducts (or adds) points directly using the scanned `cardNumber` (`DRK-...`) without needing the internal database `cardId` and **without sending any item or bill prices**. Returns the exact `pulaEquivalent` discount for your POS to deduct from the customer's bill, and logs the transaction in both your POS and PulaPartners.
### Request Body (JSON)
* `cardNumber` (string, required) — The scanned loyalty card number (e.g. `"DRK-DANGER-001"`).
* `points` (number, required) — Number of points to deduct or add (e.g. `10`).
* `action` (string, optional) — `"deduct"` (default) or `"add"`.
#### cURL Example (Deducting 10 Points at Checkout)
```bash
curl -X POST https://api.digirewardcard.com/api/store/pos/redeem \
-H "Authorization: Bearer drk_123456789" \
-H "Content-Type: application/json" \
-d '{
"cardNumber": "DRK-DANGER-001",
"points": 10,
"action": "deduct"
}'
```
#### Response Example (at Recommended 1 pt = P0.20, or P5.00 if Store Rate is 1 pt = P0.50)
```json
{
"cardId": 1,
"cardNumber": "DRK-DANGER-001",
"cardholderName": "Neo Molefe",
"tier": "Silver",
"action": "deduct",
"pointsAdjusted": 10,
"pointsDeducted": 10,
"previousPoints": 120,
"remainingPoints": 110,
"pointValuePula": 0.2,
"pulaEquivalent": 2.0,
"remainingPulaEquivalent": 22.0,
"summary": "Deducted 10 pts = P2.00 discount equivalent (1 pt = P0.20)"
}
```
---
## 3. Enroll a Customer at the Till (Ghost Accounts)
**Endpoint:** `POST /api/store/clients`
Use this endpoint when a customer is checking out at the till. If they don't have the PulaPerks app yet, the system automatically generates a **"Ghost Account"**. When the customer later downloads the app and signs up using the same phone number, email, or ID, their points and card automatically sync to their phone.
### Request Body (JSON)
* `firstName` (string, required)
* `lastName` (string, required)
* At least one unique identifier is required: `phone`, `email`, `nationalId`, or `passportNumber`
* `points` (number, optional) — Initial points to award them.
---
## 4. Adjust Customer Points by Card ID
**Endpoint:** `POST /api/store/clients/:cardId/points`
Adjusts points by numeric `cardId` and returns `points`, `pointsAdjusted`, `pointValuePula`, and `pulaEquivalent`.
### Request Body (JSON)
* `amount` (number, required) — The number of points to add or deduct.
* `action` (string, optional) — Either `"add"` (default) or `"deduct"`.
---
## 5. List All Loyalty Members & POS Transactions
* **List Members:** `GET /api/store/clients` (includes `points`, `pointValuePula`, and `pulaEquivalent` for each member).
* **List POS Points & Pula Equivalent Log:** `GET /api/store/pos/transactions` (returns total points deducted, total Pula discount equivalent given, and individual point redemption/addition records).
* **Revoke a Loyalty Card:** `DELETE /api/store/clients/:cardId`