Winner till API
Connect a point-of-sale system to Winner so members earn and spend points as part of the normal sale.
How it works
- The store owner or a manager creates a key under Store → Till connections and pastes it into the till's settings.
- At checkout the till sends the scanned card to /cards/lookup and shows the member's eligible offers.
- It calls /purchases/preview with the bill, applies the returned discount, then confirms with /purchases and an Idempotency-Key.
- If a sale is voided, the till calls /purchases/{id}/reversal (manager keys only).
Endpoints
| Method | Path | Scope |
|---|---|---|
| GET | /me | — |
| POST | /cards/lookup | cards:read |
| POST | /purchases/preview | purchases:write |
| POST | /purchases | purchases:write |
| GET | /purchases/{id} | purchases:read |
| POST | /purchases/{id}/reversal | reversals:write |
| GET | /orders | orders:read |
| GET | /orders/{id} | orders:read |
| POST | /orders/{id} | orders:write |
| GET | /bookings?day= | bookings:read |
| GET | /bookings/services | bookings:read |
| GET | /bookings/slots?serviceId=&day= | bookings:read |
| GET | /queue?branchId= | queue:read |
| POST | /giftcards/lookup | giftcards:read |
Base address: https://winnerapp.app/api/pos/v1
Example: confirm a sale
curl -X POST https://winnerapp.app/api/pos/v1/purchases \
-H "Authorization: Bearer $WINNER_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"cardInput":"<scanned code>","subtotalMinor":2500000,"currency":"SYP",
"actualDiscountMinor":0,"receiptRef":"T1-000123"}'For partner companies (one key, many stores)
Till/POS makers, delivery apps and other partners don't need each store to make a key. Once the Winner team sets up your partner account:
- Sign in to the partner area (/partner) and make a key (wp_live_… on the live site, wp_test_… on staging). It's shown once.
- Send store owners your connect link. They choose the store (and branch) and allow exactly the permissions you ask for.
- You get the connection id: back at your return address (?connection=…&state=…) or as a code the store gives you.
- Call the same till API with your key and a Winner-Connection header carrying that id. Each connection acts at that store only, as the manager who allowed it.
- Stores can disconnect you at any time (calls then answer 401). Limits: 120 calls a minute per store and 1,200 across all your stores.
curl -X POST https://winnerapp.app/api/pos/v1/cards/lookup \
-H "Authorization: Bearer wp_live_…" \
-H "Winner-Connection: <connection id>" \
-H "Content-Type: application/json" \
-d '{"cardInput":"…"}'Webhooks: hear about purchases
Add an https address under Store → Till connections → Webhooks. Winner sends a signed POST when a purchase is confirmed, reversed, or held for the Winner team, plus a test event on request.
- Check Winner-Signature with the secret shown when you added the webhook, and refuse anything older than 5 minutes.
- Reply with any 2xx within 10 seconds. Failures are retried 8 times over about a day; after 25 failures in a row the webhook is turned off and the owner is told.
- The same event may arrive twice and out of order: de-duplicate on the event id and trust data.status.
// Node.js — verify a Winner webhook (use the raw request body, before JSON parsing)
const crypto = require("node:crypto");
function verifyWinner(rawBody, header, secret) {
const { t, v1 } = Object.fromEntries(header.split(",").map((p) => p.split("=")));
if (Math.abs(Date.now() / 1000 - Number(t)) > 300) return false;
const want = crypto.createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex");
return v1.length === want.length && crypto.timingSafeEqual(Buffer.from(v1), Buffer.from(want));
}Rules
- Send the key as Authorization: Bearer wk_… — keep it on the till or your server, never in a web page.
- Amounts are integer minor units: 2500000 = 25,000 SYP.
- Use one Idempotency-Key per sale. Retrying after a timeout is safe; the same key with a different bill returns 409 IDEMPOTENCY_CONFLICT.
- Up to 120 requests a minute per key; beyond that you get 429 with Retry-After.
- Keys from the staging site start with wk_test_ and only work there — use it as your sandbox with the demo data.