Developer documentation

The Capital Quality Wallet API.

A REST API for issuing Apple Wallet and Google Wallet passes, recording sales and rewarding customers. JSON over HTTPS, OAuth 2.0, idempotent writes and signed webhooks.

BASE https://wallet.capitalquality.net/api/v1 VERSION 2026-09-01 OpenAPI 3.1 ↗ Explorer ↗ Postman ↗

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
One host, two environments. Sandbox and live share the same base URL. Your credential decides which one you are talking to: keys starting with 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

bash
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.

bash
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.

bash
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" }
  }'
201 Created
{
  "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.

http
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.

bash
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"
200 OK
{ "access_token": "…", "token_type": "Bearer", "expires_in": 3600, "scope": "loyalty:write customers:read" }
Keep secrets on the server. Never embed API keys in a browser page or a mobile app. Call the API from your POS backend or server.

Requests & responses

TopicRule
Base URLhttps://wallet.capitalquality.net/api/v1
FormatJSON bodies, UTF-8, Content-Type: application/json
MoneyInteger minor units plus ISO-4217 currency: {"amount": 12500, "currency": "KWD"} = 12.500 KWD. KWD, BHD and OMR use 3 decimals.
TimestampsISO-8601 strings in UTC
Request IDsEvery response carries X-Request-Id. Send your own (≤ 64 URL-safe characters) and it is echoed back.
VersioningMajor 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/redeem and issued-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.

GET /customers?limit=50&starting_after=cus_…
{
  "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.

400 Bad Request
{
  "error": {
    "type": "invalid_request_error",
    "code": "validation_failed",
    "message": "amount must be a positive integer (minor units)",
    "param": "sale.amount",
    "request_id": "req_…"
  }
}
HTTPtypecode
400invalid_request_errorvalidation_failed, invalid_json, missing_idempotency_key
401authentication_errorinvalid_token, token_expired, invalid_client
402plan_errorplan_limit_exceeded
403permission_errorinsufficient_scope, ip_not_allowed, tenant_suspended, location_not_allowed
404invalid_request_errorresource_not_found
409conflict_erroridempotency_in_progress, customer_exists, already_reversed
422business_rule_errorinsufficient_balance, below_minimum_purchase, earn_limit_reached, reward_unavailable, coupon_expired, coupon_exhausted, idempotency_key_reused
429rate_limit_errorrate_limited, wallet_notification_quota
5xxapi_errorinternal_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.

Wallet notification quota. Google allows at most three notifying updates per pass per 24 hours. The platform enforces this before calling Google and returns 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

HeaderExample
LW-Event-Idevt_01J9Z4…
LW-Event-Typeloyalty.points_earned
LW-Delivery-Idwhd_01J9Z4…
LW-Signaturet=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.

node.js
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)));
}
Rotating secrets. When you rotate an endpoint’s secret, the old one keeps signing for 24 hours, so a header may carry two v1 values. Respond with any 2xx quickly and do slow work in the background.

Event envelope

json
{
  "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.

EventWhen it fires
customer.createdA customer is created by the API, dashboard, enrollment page or import
customer.updatedProfile, tags or consent changed
pass.issuedA wallet pass is created and install links generated (not yet installed)
pass.installedApple device registered for updates, or Google “save” callback verified
pass.updatedNew pass content committed and pushed to Apple and Google
pass.uninstalledApple device unregistered, or Google “delete” callback verified
loyalty.points_earnedPoints or a bonus were added to an account
loyalty.points_redeemedPoints were redeemed
loyalty.transaction_reversedAn earn, redemption or adjustment was reversed
reward.issuedA voucher was issued (stamp card completed, tier, birthday, manual)
reward.redeemedA voucher was redeemed
promotion.redeemedA coupon or offer was redeemed through the API or POS screen
webhook.delivery_failedA 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
ResourceWhere
OpenAPI 3.1 document/api/v1/openapi.json
Interactive API explorer/docs/explorer
Postman collection/docs/postman
Error reference/docs/errors
System status/status