Integrate Calypx loyalty

Two ways in, pick whichever fits: a Partner API for your own backend to earn and redeem server-to-server with no counter or staff session, or a website widget - one script tag and an iframe, no backend required at all.

Quickstart

Get a key, then earn or redeem in one call.

Get a key from your admin console, send it as a bearer token on /api/v1/partner/loyalty/*, and POST a phone number plus a bill amount to get back a transaction id and balance.

First request
curl -X POST https://<your-shop-domain>/api/v1/partner/loyalty/earn \
  -H "Authorization: Bearer clpx_sk_..." \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-48213" \
  -d '{
    "phone": "9845000000",
    "billAmountPaise": 150000,
    "orderId": "order-48213"
  }'

Authentication

One key per shop, sent as a bearer token.

Authorization: Bearer clpx_sk_...

Keys are scoped to loyalty.earn and/or loyalty.redeem. Wrong scope returns 403, a missing or revoked key returns 401. Issue and revoke keys from the admin console.

Endpoints

Three calls, everything else (tiering, expiry, minimum-to-redeem) is handled for you using the shop's own settings.

POST/api/v1/partner/loyalty/earnloyalty.earn

Records a purchase and credits points to the customer's balance at your shop, creating the customer if this is their first visit.

Request body

FieldTypeNotes
phone*stringCustomer’s phone number, any common format.
billAmountPaise*integerBill amount in paise (₹1 = 100). Must be > 0.
orderId*stringYour own order id, up to 64 characters. Required - also enforces you can only ever earn once per order, no matter how the request is retried.
namestringCustomer’s name, up to 80 characters - only used the first time this phone is seen.

Response body

FieldTypeNotes
transactionIduuidThis platform’s id for the transaction - keep it for support queries.
pointsEarnedintegerPoints credited by this one call.
balanceintegerCustomer’s new total balance at your shop.
Request
{
  "phone": "9845000000",
  "billAmountPaise": 150000,
  "orderId": "order-48213",
  "name": "Ananya Rao"
}
Response
{
  "transactionId": "b7e1c9de-...",
  "pointsEarned": 150,
  "balance": 890
}
POST/api/v1/partner/loyalty/redeemloyalty.redeem

Redeems points against a bill, returning the discounted amount to charge the customer. Omit points to redeem the maximum the shop's own rules allow.

Request body

FieldTypeNotes
phone*stringCustomer’s phone number.
billAmountPaise*integerBill amount in paise, before this redemption. Must be > 0.
pointsintegerPoints to redeem. Omit to redeem the maximum allowed.
orderId*stringYour own order id, up to 64 characters. Required - the same order can only ever be redeemed once.

Response body

FieldTypeNotes
transactionIduuid
pointsRedeemedintegerPoints actually redeemed by this call.
valuePaiseintegerRupee value of the points redeemed, in paise.
netPayablePaiseintegerbillAmountPaise minus valuePaise - what to actually charge.
balanceintegerCustomer’s new balance after this redemption.
Request
{
  "phone": "9845000000",
  "billAmountPaise": 200000,
  "points": 500,
  "orderId": "order-48214"
}
Response
{
  "transactionId": "1a2b3c4d-...",
  "pointsRedeemed": 500,
  "valuePaise": 50000,
  "netPayablePaise": 150000,
  "balance": 390
}
GET/api/v1/partner/loyalty/wallet?phone=9845000000no scope required

Looks up a customer's current balance at your shop only - never across other shops on the platform, even ones sharing the same phone number.

Response body

FieldTypeNotes
foundbooleanFalse if this phone has never earned at your shop.
balanceintegerCurrent points balance. 0 if not found.
balanceValuePaiseintegerRupee value of that balance, in paise.
Response
{
  "found": true,
  "balance": 890,
  "balanceValuePaise": 89000
}

Website widget

One script tag, no backend - for a website to offer a balance check or earn.

In development

The widget is still being built. It will use a separate, public key type - restricted to balance and earn only, safe to paste into page HTML - so redeeming will still require the Partner API above. Docs land here once it ships.

Refunds

Dashboard-only today - an owner action, not something your key can call - but it changes a balance your integration reads, so it's documented here in full.

POST/api/v1/transactions/:id/refundowner session, not a partner key

Refunds part or all of a past bill. Refunding a redeem transaction gives the spent points back; refunding an earn transaction takes the earned points away. Partial refunds on the same bill are cumulative and proportional, with no rounding drift, and a second request racing the same bill is rejected rather than corrupting the balance.

Request body

FieldTypeNotes
amountPaiseintegerAmount to refund, in paise. Omit to refund whatever remains unrefunded on this bill.
reasonstringOptional free-text note, shown on the transaction later.

Response body

FieldTypeNotes
refundedAmountPaiseintegerAmount refunded by this one call.
pointsAdjustedintegerPoints moved by this call - negative for a redeem refund, positive for an earn refund.
totalRefundedAmountPaiseintegerCumulative refunded amount on this bill across every call so far.
remainingRefundableAmountPaiseinteger0 once the bill is fully refunded.
fullyRefundedboolean
balanceintegerCustomer's new balance after this refund.
Request
{
  "amountPaise": 100000,
  "reason": "Item returned"
}
Response
{
  "refundedAmountPaise": 100000,
  "pointsAdjusted": -50,
  "totalRefundedAmountPaise": 100000,
  "remainingRefundableAmountPaise": 150000,
  "fullyRefunded": false,
  "balance": 75
}

Why this is here even though your key can't call it

An owner can refund any bill from the dashboard, including one your key created - so a customer's balance can change without your system initiating it. Don't treat your own running total as authoritative; call the wallet lookup endpoint above when you need the current balance, not a locally tracked sum.

Errors

One envelope for every failure: { error: { code, message } }.

HTTPCodeMeaning
400bad_requestMalformed request - a field is missing or the wrong shape.
422validation_failedRequest parsed, but a field failed validation (e.g. bill amount ≤ 0).
401unauthorizedMissing, unknown, or revoked API key.
403forbiddenKey is valid but not scoped for this endpoint.
404not_foundReferenced resource does not exist.
409conflictSame idempotency key reused with a different request body.
429rate_limitedToo many requests - back off and retry.
500internal_errorOur fault, not yours - safe to retry.
Example error
{
  "error": {
    "code": "forbidden",
    "message": "This key is not scoped for loyalty.redeem."
  }
}

Ready to integrate?

Keys are issued per shop from the platform admin console. Already a Calypx shop? Ask whoever onboarded you to issue one from Admin → API keys.