Card typesHow it worksFAQPricingDemoAbout usSign in
Join now →DashboardFinish setup

Dokan Loyalty in your POS

A stamp or points with every order, and news in your system with every scan at the counter. One set of numbers, and the customer's Wallet card updates by itself.

  1. 1Make a keyThe shop's owner makes one in Dashboard → Developers
  2. 2Find or add a customerBy phone number or the Wallet card's barcode
  3. 3Give a stampWith your order number. Sent twice, it still counts once

Start in 10 minutes

Every address starts with https://api.dokanloyalty.com/v1. JSON in, JSON out, no SDK needed.

The shop's owner makes a key in Dashboard → Developers and gives it to you. It comes with the ৳999 plan and above. Read the shop first, to check the key works:

curl "https://api.dokanloyalty.com/v1/shop" \
  -H "Authorization: Bearer $DOKAN_API_KEY"

Keys and access

Send Authorization: Bearer dl_live_… with every request. A key belongs to one shop, and the shop comes from the key alone.

  • Read only: can read, can't change anything.
  • Full access: stamps and points, adding customers, refunds, messages and online requests.
  • Keep keys on your server. A call from a browser answers browser_not_allowed.
  • A key is shown once, when it's made. Turned off, it stops from the next request. To replace one, make a new key and turn the old one off.

Answers

Success has data, failure has error. Both have a requestId: quote it if you ask us about a call.

{
  "data": { … },
  "requestId": "req_7f3a91c2d0e4b816"
}
  • Phone numbers: you may send a whole number, but answers always mask it (017••••5678). To match customers, use customerId or your own externalId.
  • Money: billAmount is in whole taka. The shop's balance never appears, only scansLeft (null means no limit).
  • Time: always ISO 8601, in UTC.

Error codes

Go by error.code; the message may change. Nothing changes on any error except a 5xx, which is safe to retry.

invalid_key401The key is missing, wrong or turned off
read_only_key403This key can only read
api_not_in_plan403The shop's plan has no API
browser_not_allowed403Called from a browser
account_stopped402The shop is stopped for an unpaid bill
no_credit402This month's scans are used up
customer_not_found404No such customer
order_not_found404This order earned no stamps or points
reward_ready409The card is full, give the reward first
reward_not_ready409Not enough stamps for the reward
not_enough_points409Not that many points
no_card_of_type409The customer doesn't have this card
customer_limit_reached409The plan's customer limit is reached
order_conflict409This order was already counted with other details
refund_conflict409This refundId was used for something else
refund_too_large409More than is left of the order
nothing_to_refund409Nothing left to take back
already_used409The customer already used them; the owner corrects it by hand
idempotency_conflict409This key was used for a different request
idempotency_in_progress409The first request is still running, retry shortly
validation422Something sent isn't right, see details
idempotency_key_required422No Idempotency-Key was sent
rate_limited429Too many requests, wait for Retry-After
internal500A problem on our side, retry the same request

Counting once

If your POS loses the network, just send it again. Nothing happens twice.

  • Orders: give orderId on POST /actions. Sent again, it answers the first result with duplicate: true.
  • Refunds: refundId works the same way.
  • Other writes: send an Idempotency-Key header (8 to 64 characters, a UUID works). For 7 days the same key answers the first result, with Idempotent-Replay: true. A refused request frees its key.

Limits

  • 120 requests a minute per key. Over that: 429 with a Retry-After header.
  • Messages to one customer: 30 an hour per key.
  • Each stamp, reward or points action costs one scan, as at the counter. A refund doesn't give the scan back.
  • Lists give at most 50 at a time; GET /actions at most 100.

Shop and cards

The shop's state, its card rules and open branches.

The shop

GET/v1/shopAny key

Name, plan, scans left and the shop's state (state: active, due, grace, stopped).

curl "https://api.dokanloyalty.com/v1/shop" \
  -H "Authorization: Bearer $DOKAN_API_KEY"
Answer
{
  "data": {
    "id": "cm1b0a7xk0000",
    "name": "Cafe Rangpur",
    "category": "cafe",
    "plan": { "code": "medium", "name": "Medium shop" },
    "scansLeft": 842,
    "scansResetAt": "2026-12-01T00:00:00.000Z",
    "state": "active"
  },
  "requestId": "req_7f3a91c2d0e4b816"
}

Card rules

GET/v1/cardsAny key

The shop's stamp and points cards: stamps for a reward, taka for points.

curl "https://api.dokanloyalty.com/v1/cards" \
  -H "Authorization: Bearer $DOKAN_API_KEY"
Answer
{
  "data": [
    {
      "id": "cm1b0a9pq0002",
      "card": "stamp",
      "name": "Coffee offer",
      "offer": "Coffee offer",
      "paused": false,
      "rewardName": "Free coffee",
      "stampsRequired": 8,
      "earnSpendBdt": null,
      "earnPoints": null,
      "redeemPoints": null,
      "redeemValueBdt": null,
      "onlineOrdersOn": true
    }
  ],
  "requestId": "req_7f3a91c2d0e4b816"
}

Open branches

GET/v1/branchesAny key

Where the branchId for a stamp comes from.

curl "https://api.dokanloyalty.com/v1/branches" \
  -H "Authorization: Bearer $DOKAN_API_KEY"
Answer
{
  "data": [
    { "id": "cm1b0b2rt0003", "name": "Dhanmondi", "address": "Road 27", "isMain": true }
  ],
  "requestId": "req_7f3a91c2d0e4b816"
}

Customers

Find and add customers, and send them their card.

List customers

GET/v1/customersAny key

Newest first. hasMore says whether there is another page.

qPart of the namestring
externalIdYour system's id for the customerstring
cardWhich cardstamp | points
pagePage, from 1integer
pageSizeHow many a page, at most 50integer
curl "https://api.dokanloyalty.com/v1/customers?pageSize=25" \
  -H "Authorization: Bearer $DOKAN_API_KEY"
Answer
{
  "data": {
    "items": [ … ],
    "page": 1,
    "pageSize": 25,
    "hasMore": true
  },
  "requestId": "req_7f3a91c2d0e4b816"
}

Find by barcode or phone

POST/v1/customers/lookupAny key

Send what your POS reads from a Wallet card, or a whole phone number.

codeThe Wallet card's barcode text, or a phone numberrequiredstring
curl -X POST "https://api.dokanloyalty.com/v1/customers/lookup" \
  -H "Authorization: Bearer $DOKAN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "code": "01712345678"
  }'
Answer
{
  "data": {
    "id": "cm3x8q2vd0001",
    "externalId": "user-42",
    "name": "Nusrat Jahan",
    "maskedPhone": "017••••5678",
    "cards": ["stamp"],
    "stamps": 7,
    "points": 0,
    "rewardReady": false,
    "rewardsClaimed": 2,
    "lastScanAt": "2026-11-10T08:41:12.000Z",
    "joinedAt": "2026-10-03T05:12:40.000Z"
  },
  "requestId": "req_7f3a91c2d0e4b816"
}

Add a customer

POST/v1/customersFull access key

201 when new, 200 when they already exist. Send the customer the cardLink to save the card to their Wallet.

nameThe customer's namerequiredstring
phoneA Bangladesh mobile numberrequiredstring
cardWhich cardstamp | points
externalIdYour system's id, one per customerstring
curl -X POST "https://api.dokanloyalty.com/v1/customers" \
  -H "Authorization: Bearer $DOKAN_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Nusrat Jahan",
    "phone": "01712345678",
    "card": "stamp",
    "externalId": "user-42"
  }'
Answer
{
  "data": {
    "created": true,
    "customer": { … },
    "cardLink": "https://dokanloyalty.com/bn/join/…"
  },
  "requestId": "req_7f3a91c2d0e4b816"
}

One customer

GET/v1/customers/:idAny key

Their balances and which cards they hold.

curl "https://api.dokanloyalty.com/v1/customers/cm3x8q2vd0001" \
  -H "Authorization: Bearer $DOKAN_API_KEY"
Answer
{
  "data": {
    "id": "cm3x8q2vd0001",
    "externalId": "user-42",
    "name": "Nusrat Jahan",
    "maskedPhone": "017••••5678",
    "cards": ["stamp"],
    "stamps": 7,
    "points": 0,
    "rewardReady": false,
    "rewardsClaimed": 2,
    "lastScanAt": "2026-11-10T08:41:12.000Z",
    "joinedAt": "2026-10-03T05:12:40.000Z"
  },
  "requestId": "req_7f3a91c2d0e4b816"
}

A customer's history

GET/v1/customers/:id/historyAny key

Newest first, 20 a page. Send nextBefore as before for the next page.

beforeThose before this timedate-time
curl "https://api.dokanloyalty.com/v1/customers/cm3x8q2vd0001/history" \
  -H "Authorization: Bearer $DOKAN_API_KEY"
Answer
{
  "data": {
    "items": [
      {
        "id": "cm3y1k8aa0009",
        "action": "stamp",
        "stamps": 1,
        "points": 0,
        "balance": 7,
        "orderId": "order-2041",
        "branchId": null,
        "createdAt": "2026-11-10T08:41:12.000Z"
      }
    ],
    "nextBefore": null
  },
  "requestId": "req_7f3a91c2d0e4b816"
}

Card link

GET/v1/customers/:id/card-linkAny key

The customer's card page, where they save it to Apple Wallet or Google Wallet.

cardWhich cardstamp | points
curl "https://api.dokanloyalty.com/v1/customers/cm3x8q2vd0001/card-link?card=stamp" \
  -H "Authorization: Bearer $DOKAN_API_KEY"
Answer
{
  "data": {
    "card": "stamp",
    "url": "https://dokanloyalty.com/bn/join/…"
  },
  "requestId": "req_7f3a91c2d0e4b816"
}

Message one customer

POST/v1/customers/:id/messageFull access key

One free message on their Wallet card. If the card isn't in a Wallet, the answer is no_wallet.

messageThe messagerequiredstring
cardWhich cardstamp | points
curl -X POST "https://api.dokanloyalty.com/v1/customers/cm3x8q2vd0001/message" \
  -H "Authorization: Bearer $DOKAN_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "Your free coffee is ready!"
  }'
Answer
{
  "data": {
    "devices": 1
  },
  "requestId": "req_7f3a91c2d0e4b816"
}

Stamps and points

All the counter's rules apply, and the Wallet card updates by itself.

Stamp, reward or points

POST/v1/actionsFull access key

Name the customer by exactly one of customerId, externalId, phone or code. points_add takes points or billAmount; a bill is turned into points by the shop's rule.

actionWhat to dorequiredstamp | reward | points_add | points_use
orderIdYour order number, so it counts oncerequiredstring
customerIdDokan Loyalty's id for the customerstring
externalIdYour system's id for the customerstring
phoneThe whole mobile numberstring
codeThe Wallet card's barcode text, or a phone numberstring
cardIdWhich offer (an id from GET /cards); left out = the customer's oldest running offer of that typestring
countHow many stamps, 1 to 20integer
pointsHow many points, 1 to 1000integer
billAmountOn points_add, the bill in whole takainteger
branchIdWhich branch it happened atstring
curl -X POST "https://api.dokanloyalty.com/v1/actions" \
  -H "Authorization: Bearer $DOKAN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "action": "stamp",
    "phone": "01712345678",
    "orderId": "order-2041"
  }'
Answer
{
  "data": {
    "action": "stamp",
    "customerId": "cm3x8q2vd0001",
    "externalId": "user-42",
    "card": "stamp",
    "cardId": "cm1b0a9pq0002",
    "offer": "Coffee offer",
    "delta": 1,
    "balance": 7,
    "rewardReady": false,
    "scansLeft": 842,
    "orderId": "order-2041",
    "activityId": "cm3y1k8aa0009",
    "duplicate": false
  },
  "requestId": "req_7f3a91c2d0e4b816"
}

What happened

GET/v1/actionsAny key

Every scan since a time, oldest first. Use it to catch up after missed webhooks.

sinceFrom this timerequireddate-time
cursornextCursor from the last answerstring
limitHow many, at most 100integer
curl "https://api.dokanloyalty.com/v1/actions?since=2026-11-10T00:00:00Z&limit=50" \
  -H "Authorization: Bearer $DOKAN_API_KEY"
Answer
{
  "data": {
    "items": [ … ],
    "nextCursor": null
  },
  "requestId": "req_7f3a91c2d0e4b816"
}

Refund

POST/v1/refundsFull access key

Takes back the stamps or points an order earned. Without amount, all that is left. If the customer has used them, the answer is already_used.

orderIdThe order being refundedrequiredstring
refundIdYour refund number, so it happens oncerequiredstring
cardWhich card, if the order earned on more than onestamp | points
cardIdWhich offer (an id from GET /cards); left out = the customer's oldest running offer of that typestring
amountHow much to take back; all if left outinteger
curl -X POST "https://api.dokanloyalty.com/v1/refunds" \
  -H "Authorization: Bearer $DOKAN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "orderId": "order-2041",
    "refundId": "refund-77"
  }'
Answer
{
  "data": {
    "refundId": "refund-77",
    "orderId": "order-2041",
    "customerId": "cm3x8q2vd0001",
    "card": "stamp",
    "amount": 1,
    "balance": 6,
    "left": 0,
    "activityId": "cm3y1m2bb0011",
    "duplicate": false
  },
  "requestId": "req_7f3a91c2d0e4b816"
}

Online orders

Requests customers send for their delivery app orders.

List requests

GET/v1/order-requestsAny key

Waiting, approved or declined requests.

statusWhich state, pending by defaultpending | approved | declined
pagePage, from 1integer
curl "https://api.dokanloyalty.com/v1/order-requests?status=pending" \
  -H "Authorization: Bearer $DOKAN_API_KEY"
Answer
{
  "data": {
    "items": [
      {
        "id": "cm3z0p1cc0020",
        "orderId": "FP-88213",
        "platform": "foodpanda",
        "status": "pending",
        "wantsReward": false,
        "points": null,
        "declineReason": null,
        "card": "stamp",
        "customer": { "id": "cm3x8q2vd0001", "externalId": null, "name": "Nusrat Jahan", "maskedPhone": "017••••5678" },
        "createdAt": "2026-11-10T08:41:12.000Z",
        "decidedAt": null
      }
    ],
    "page": 1,
    "pageSize": 30,
    "total": 1
  },
  "requestId": "req_7f3a91c2d0e4b816"
}

Approve

POST/v1/order-requests/:id/approveFull access key

On a stamp card, adds one stamp. On a points card, points is needed.

pointsOn a points card, how many pointsinteger
curl -X POST "https://api.dokanloyalty.com/v1/order-requests/cm3z0p1cc0020/approve" \
  -H "Authorization: Bearer $DOKAN_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{}'
Answer
{
  "data": {
    "request": { … },
    "scansLeft": 841
  },
  "requestId": "req_7f3a91c2d0e4b816"
}

Decline

POST/v1/order-requests/:id/declineFull access key

With a reason if you like: not_found, already_given or other_shop.

reasonWhy it's declinedstring
curl -X POST "https://api.dokanloyalty.com/v1/order-requests/cm3z0p1cc0020/decline" \
  -H "Authorization: Bearer $DOKAN_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{}'
Answer
{
  "data": {
    "request": { … }
  },
  "requestId": "req_7f3a91c2d0e4b816"
}

Webhooks

In Dashboard → Developers → Webhooks, give an https address and tick the news you want. When it happens, that address gets a POST.

customer.joinedA customer joined a card
scan.stamp_addedA stamp was given
scan.reward_givenA reward was given
scan.points_addedPoints were added
scan.points_usedPoints were used
scan.undoneA scan was undone at the counter
scan.taken_offTaken off by hand or by refund
order_request.createdA new online request
order_request.approvedA request was approved
order_request.declinedA request was declined

source says where it came from: counter, api, online_order or join_page. Don't want news of your own calls? Skip api.

JSON
{
  "id": "evt_5f0c2a8e7b1d4c3e9a6f0d4b",
  "type": "scan.stamp_added",
  "createdAt": "2026-11-10T08:41:12.000Z",
  "source": "counter",
  "data": {
    "customerId": "cm3x8q2vd0001",
    "externalId": "user-42",
    "maskedPhone": "017••••5678",
    "card": "stamp",
    "delta": 1,
    "balance": 7,
    "branchId": null,
    "orderId": null,
    "activityId": "cm3y1k8aa0009"
  }
}

Check that it's really from us

Each message has a Dokan-Signature header: t=time,v1=signature. Make the HMAC-SHA256 of t.body with your secret and compare. Use the body exactly as it arrived. Refuse anything over 5 minutes old.

import { createHmac, timingSafeEqual } from 'node:crypto';

function isFromDokan(rawBody, header, secret) {
  const parts = Object.fromEntries(
    header.split(',').map((p) => p.split('=')),
  );
  if (Date.now() / 1000 - Number(parts.t) > 300) return false;

  const mine = createHmac('sha256', secret)
    .update(`${parts.t}.${rawBody}`)
    .digest('hex');
  const theirs = Buffer.from(parts.v1 ?? '');
  return theirs.length === mine.length
    && timingSafeEqual(Buffer.from(mine), theirs);
}

If it doesn't arrive

  • Answer 2xx within 10 seconds, and do heavy work afterwards.
  • On any other answer it is tried again after 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours and 24 hours. Redirects are not followed.
  • The same news can arrive twice or out of order. Use id to ignore repeats.
  • An address that gets nothing through for 3 days switches off. You can turn it on again in the dashboard.
  • If you missed something, catch up with GET /actions.