Skip to content

Build with the API

Passkaar runs loyalty cards for shops in Pakistan. A shop designs its card in the Passkaar portal, its customers keep the card in Apple Wallet or Google Wallet, and every stamp, point or rupee on it is recorded by Passkaar. The integration API lets your software do what a cashier does at the counter: sign a customer up, give them value for a sale, let them spend it, and take it back on a refund. Passkaar updates the card on the customer’s phone after each change.

The API is JSON over HTTPS under one address, with a secret key per connection. These guides walk through it with curl, in the order you will need it. Each one runs as written, top to bottom, against a test shop: paste the commands into a terminal and you get answers like the ones shown.

Connecting only a till? Point of sale (POS) has just what a till needs, in six short pages.

  1. Getting a key: a test shop, its key, and your first call.
  2. Signing a customer up: a new card and the link that puts it on the customer’s phone.
  3. A sale at the counter: find the card the customer shows, give points for the bill, spend them, and retry safely.
  4. An online order and its refund: earning for a store account, holding value at checkout, partial and full refunds.
  5. Verifying a webhook: a receiver that checks Passkaar’s signature, and the events it hears.
  6. From test to live: what changes when a real shop gives you its key.
  7. Handling errors: the shape of an error, which ones to retry, and the common ones you will meet.
  8. The TypeScript library: a typed client that retries safely and checks webhooks in one line. Not published yet.
  • A terminal with curl and jq (brew install jq on a Mac, sudo apt install jq on Debian or Ubuntu). jq keeps each answer in a file and picks out the ids the next command needs.
  • A key. Getting a key says how to get one for a test shop.
  • For the webhook guide, Node.js 18 or later.

Every guide begins by setting two variables. The key is read without echoing it, so it does not land in your shell’s history:

Every guide starts here
export PASSKAAR_API=https://api.passkaar.com/integrations/v1
printf 'Your key: '; read -rs PASSKAAR_KEY; echo; export PASSKAAR_KEY
  • A key is a secret that lives on your server. Never put it in a web page, a phone app or a theme file, and never send it to a customer.
  • Every write can be retried. Send an Idempotency-Key header and the shop’s own reference (an invoice or order number). The same request again answers the first result instead of doing it twice.
  • Money is whole rupees. A bill of Rs 2,450 is {"total": 2450, "currency": "PKR"}.
  • Answers only ever gain fields. Ignore fields and error codes you do not know.

Everything else is in the API reference, the webhook events and the error codes. The same calls are in the Postman collection.