Overview
The API lets your POS, e-commerce store, mobile app or back office talk to Capital Quality Wallet. With it you can:
- Enroll customers and issue Apple Wallet and Google Wallet passes
- Record sales and award points or stamps — in one call
- Redeem rewards, vouchers and coupons at the counter
- Create and manage promotions and coupon codes
- Refresh passes and send lock-screen messages
- Receive real-time events through signed webhooks
lw_test_ reach the sandbox, lw_live_ reach production.Quickstart
From zero to your first rewarded sale in four steps.
1. Create a sandbox API key
Sign in to the dashboard, open Developers → API keys and create a test key. Choose only the scopes you need. The secret is shown once — store it on your server.
2. Check your credential
curl https://wallet.capitalquality.net/api/v1/me \
-H "Authorization: Bearer lw_test_…"3. Enroll a customer and issue a pass
The response contains the customer, the loyalty account and install links for Apple Wallet, Google Wallet, a landing page and a QR code. Send the landing link by SMS or show the QR at the counter.
curl -X POST https://wallet.capitalquality.net/api/v1/enrollments \
-H "Authorization: Bearer lw_test_…" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: enroll-96550000000" \
-d '{ "customer": { "phone": "+96550000000", "first_name": "Sara" } }'4. Record a sale
Amounts are integers in minor units — 4500 is 4.500 KWD. Retries must reuse the same Idempotency-Key; the platform will never award twice.
curl -X POST https://wallet.capitalquality.net/api/v1/pos/sales \
-H "Authorization: Bearer lw_test_…" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: sale-R-10427" \
-d '{
"customer": { "lookup": { "phone": "+96550000000" } },
"sale": { "external_id": "R-10427", "amount": 4500, "currency": "KWD" }
}'
{
"object": "pos_sale",
"points_awarded": 45,
"stamps_awarded": 1,
"balance": { "points": 165, "stamps": 7, "tier": "Gold" },
"issued_rewards": [],
"pass_update": { "status": "queued", "passes": 1 },
"transaction": { "id": "txn_…" },
"account": { "id": "acc_…", "points_balance": 165 }
}Authentication
Every request (except /health and /openapi.json) needs a bearer credential. Choose either method:
Scoped API keys
Create keys in the dashboard with exactly the scopes they need. Keys can be rotated at any time and optionally restricted to an IP allow-list or to specific branches.
Authorization: Bearer lw_live_…OAuth 2.0 client credentials
Exchange a client ID and secret for a short-lived access token, then send it as a bearer token.
curl -X POST https://wallet.capitalquality.net/api/v1/oauth/token \
-u "$CLIENT_ID:$CLIENT_SECRET" \
-d grant_type=client_credentials \
-d scope="loyalty:write customers:read"
{ "access_token": "…", "token_type": "Bearer", "expires_in": 3600, "scope": "loyalty:write customers:read" }Requests & responses
| Topic | Rule |
|---|---|
| Base URL | https://wallet.capitalquality.net/api/v1 |
| Format | JSON bodies, UTF-8, Content-Type: application/json |
| Money | Integer minor units plus ISO-4217 currency: {"amount": 12500, "currency": "KWD"} = 12.500 KWD. KWD, BHD and OMR use 3 decimals. |
| Timestamps | ISO-8601 strings in UTC |
| Request IDs | Every response carries X-Request-Id. Send your own (≤ 64 URL-safe characters) and it is echoed back. |
| Versioning | Major version in the path (/v1). Additive changes never break you; breaking changes ship as /v2 with at least 12 months of overlap. Responses include LW-API-Version. |
Idempotency
Networks fail. Send an Idempotency-Key header and a retried request returns the original response instead of doing the work twice.
- Required on
earn,redeem,adjust,reverse,pos/sales,coupons/redeemandissued-rewards/{id}/redeem; optional on other POSTs. - Keys are kept for 24 hours. Use something unique per operation, such as your receipt number.
- Replayed responses carry
Idempotent-Replayed: true. - Same key with a different body →
422 idempotency_key_reused. Retry while the first request is still running →409 idempotency_in_progress.
Pagination
List endpoints use cursors. Pass limit (1–100) and starting_after with the last ID you received.
{
"object": "list",
"data": [ … ],
"has_more": true,
"next_cursor": "cus_…"
}Errors
Errors share one envelope. Use type to branch your logic, code for the specific cause, and quote request_id when you contact support.
{
"error": {
"type": "invalid_request_error",
"code": "validation_failed",
"message": "amount must be a positive integer (minor units)",
"param": "sale.amount",
"request_id": "req_…"
}
}| HTTP | type | code |
|---|---|---|
| 400 | invalid_request_error | validation_failed, invalid_json, missing_idempotency_key |
| 401 | authentication_error | invalid_token, token_expired, invalid_client |
| 402 | plan_error | plan_limit_exceeded |
| 403 | permission_error | insufficient_scope, ip_not_allowed, tenant_suspended, location_not_allowed |
| 404 | invalid_request_error | resource_not_found |
| 409 | conflict_error | idempotency_in_progress, customer_exists, already_reversed |
| 422 | business_rule_error | insufficient_balance, below_minimum_purchase, earn_limit_reached, reward_unavailable, coupon_expired, coupon_exhausted, idempotency_key_reused |
| 429 | rate_limit_error | rate_limited, wallet_notification_quota |
| 5xx | api_error | internal_error, upstream_unavailable |
A 404 is also returned for IDs that belong to another business — the API never reveals whether they exist.
Rate limits
Limits apply per credential, per minute. Every response includes RateLimit-Limit, RateLimit-Remaining and RateLimit-Reset. When you exceed the limit you get 429 with a Retry-After header — wait that many seconds, then retry with the same idempotency key.
429 wallet_notification_quota when a message would exceed it.Scopes
Give each key only what it needs. A cashier POS usually needs loyalty:write and customers:read.
customers:readcustomers:writeloyalty:readloyalty:writerewards:readrewards:writepromotions:readpromotions:writepasses:readpasses:writeprograms:readwebhooks:manageusage:read
Endpoints
Every endpoint, grouped by resource. Full request and response schemas are in the OpenAPI document and the interactive explorer.
Webhooks
Register an HTTPS endpoint and we POST an event to it whenever something happens — a pass is installed, points are earned, a coupon is redeemed. Deliveries are signed with HMAC-SHA256, retried with exponential backoff, moved to a dead-letter queue after the final attempt, and can be replayed from the dashboard or the API.
Headers
| Header | Example |
|---|---|
LW-Event-Id | evt_01J9Z4… |
LW-Event-Type | loyalty.points_earned |
LW-Delivery-Id | whd_01J9Z4… |
LW-Signature | t=1790000000,v1=5257a869e7ec… |
Verifying the signature
Recompute HMAC_SHA256(secret, t + "." + raw_body), compare it in constant time with any v1 value, and reject events older than 300 seconds. Store processed LW-Event-Ids for at least 24 hours to ignore duplicates.
import crypto from 'node:crypto';
export function verify(rawBody, header, secret) {
const parts = header.split(',').map((p) => p.split('='));
const t = parts.find(([k]) => k === 't')?.[1];
const sigs = parts.filter(([k]) => k === 'v1').map(([, v]) => v);
if (!t || Math.abs(Date.now() / 1000 - Number(t)) > 300) return false;
const expected = crypto.createHmac('sha256', secret)
.update(`${t}.${rawBody}`).digest('hex');
return sigs.some((s) => s.length === expected.length &&
crypto.timingSafeEqual(Buffer.from(s), Buffer.from(expected)));
}v1 values. Respond with any 2xx quickly and do slow work in the background.Event envelope
{
"id": "evt_01J9Z4M8Q5…",
"object": "event",
"type": "loyalty.points_earned",
"api_version": "2026-09-01",
"created": "2026-09-27T10:21:07.412Z",
"livemode": true,
"provenance": { "source": "api", "verification": "platform_verified" },
"data": { "object": { … } }
}Event types
Each event states its provenance, so you know whether the platform verified it, observed it from Apple or Google, or inferred it.
| Event | When it fires |
|---|---|
customer.created | A customer is created by the API, dashboard, enrollment page or import |
customer.updated | Profile, tags or consent changed |
pass.issued | A wallet pass is created and install links generated (not yet installed) |
pass.installed | Apple device registered for updates, or Google “save” callback verified |
pass.updated | New pass content committed and pushed to Apple and Google |
pass.uninstalled | Apple device unregistered, or Google “delete” callback verified |
loyalty.points_earned | Points or a bonus were added to an account |
loyalty.points_redeemed | Points were redeemed |
loyalty.transaction_reversed | An earn, redemption or adjustment was reversed |
reward.issued | A voucher was issued (stamp card completed, tier, birthday, manual) |
reward.redeemed | A voucher was redeemed |
promotion.redeemed | A coupon or offer was redeemed through the API or POS screen |
webhook.delivery_failed | A delivery moved to the dead-letter queue (sent to your other endpoints) |
SDKs & examples
Complete, runnable POS integrations — enroll, sell, retry safely, check the balance and receive webhooks — are available in six languages, plus a typed TypeScript SDK.
cURLNode.jsPythonJavaPHPC#TypeScript SDK| Resource | Where |
|---|---|
| OpenAPI 3.1 document | /api/v1/openapi.json |
| Interactive API explorer | /docs/explorer |
| Postman collection | /docs/postman |
| Error reference | /docs/errors |
| System status | /status |