API Reference for Shops and Developers
One page for both people. The shop owner reads the first part: switch the API on, make a key, add a webhook. The developer reads the rest: how to sign in, every call with a real request and answer, webhooks with working signature code, limits, errors and ready recipes.
For the shop owner
Part 1 · for the shop
This part is for the person who owns the BazaarPOS account. You do not write any code. You switch the feature on, make a key, and give your developer two things: the address and the key.
1 What you need
- The Enterprise plan. On any other plan the screen only shows an upgrade note and nothing below works. Ask us to add it to your plan.
- Sign in as the owner (Admin). Other staff do not see this screen.
- The online (cloud) app or the Windows desktop app. Both work the same way.
2 Switch it on
- Open Settings → System & Admin → API & Webhooks.
- Switch on API access. Everything is off until you do this, even if keys already exist. A key made earlier will answer "API access is switched off" until then.
- Switch on Webhooks only if your developer needs to be told when something happens (see the webhook part below). The two switches are separate.
3 Make a key
- Press Make a key and give it a name that says who uses it, for example Website or Accountant reports. One key per tool is best, so you can switch off one without stopping the others.
- Choose what it may do. Choose Read only or Read and write. A read-only key can only look at data. A write key can also create and change products, customers, orders, coupons and gift cards. Give write only when it is needed.
- The key (it starts with
bpk_) is shown once. Copy it now and send it to your developer through a safe channel. We store only a scrambled form, so nobody, including us, can show it to you again. If it is lost, delete it and make a new one.
4 Give your developer these two things
- The address shown on the screen under "Address for your developer". It ends with
/open. - The key you just made.
- Also send them this page, and the link
…/open/openapi.json(the machine-readable description, which needs no key).
5 Keeping it safe
- Treat a key like a password. Anyone who has a write key can create bills and issue gift cards in your name.
- Never put a key inside a website page or a phone app that customers can open. It must stay on your developer's own server.
- To stop a key at once, switch it off with its on/off switch, or delete it, in the key list. It stops working within about 15 seconds. The list shows when each key was last used, so you can spot one that nobody uses any more.
- To stop everything at once, switch API access off. Your shop and billing carry on normally.
- The API cannot do anything that changes your settings, users, licence, or reports. It covers products, customers, orders, coupons and gift cards only.
6 Webhooks: messages sent to your developer's server
- Press Add address under Webhook addresses. Enter a name and the full address on your developer's server, for example
https://shop.example.com/hooks/bazaarpos. - Choose Send all events or tick only the events you need.
- The signing secret (it starts with
whsec_) is shown when you add it. Give it to your developer; it lets their server check that a message really came from BazaarPOS. - Press Test. Your developer's server should receive a
pingand the screen shows OK. If it shows an error, it tells you what went wrong (for example "Your server answered 404"). - The delivery log lists every message with its result and number of tries. A message that failed all its tries has a Send again button.
https:// addresses on the public internet. A desktop installation sends from the shop PC itself, so an address inside your own network (such as http://192.168.1.20:8080/hook) also works and no data goes through our cloud.Quick start (5 minutes)
Part 2 · for the developer
Get the key and the switches from the shop owner (see above). Then:
curl "https://www.bazaarpos.in/pos-app-backend/api/v1/open/ping" \
-H "Authorization: Bearer bpk_YOUR_KEY_HERE"
HTTP 200
{
"ok": true,
"apiVersion": "1",
"tenantId": 1,
"storeId": 1,
"canWrite": true
}
ok: true means the key works. tenantId is the shop's business number, storeId is the branch the key is limited to (or null for all branches), and canWrite tells you whether this key may change data. Now list products:
curl "https://www.bazaarpos.in/pos-app-backend/api/v1/open/products?limit=2" \
-H "Authorization: Bearer bpk_YOUR_KEY_HERE"
If you get 401, 403 or 429, see the error table — every error says in plain words what to fix.
Address, format and versions
| Base address | https://www.bazaarpos.in/pos-app-backend/api/v1/openThe owner's screen shows the exact address for the shop (Settings → System & Admin → API & Webhooks → "Address for your developer"). Use that one. For a desktop installation it is the shop PC's own address, usually on the local network. |
| Protocol | HTTPS only for the online app. The desktop app uses its own certificate; see "Desktop" below. |
| Format | JSON in and out. Send Content-Type: application/json with POST and PUT. Dates in responses are ISO 8601 text (2026-11-20T07:34:46.000Z) on most records; the delivery log and key list use Unix milliseconds. |
| Money | Plain numbers in the shop's currency (550 means 550 rupees), never in paise or cents. Send numbers, not text. |
| Version | The address contains /v1/. We add new fields and new endpoints inside v1 without notice, so ignore fields you do not know. A change that could break your code would go to a new version number. |
| Call from your server | Keep the key on your own server. Do not call the API from browser JavaScript or a mobile app: anyone could read the key from there. |
| Machine-readable description | GET https://www.bazaarpos.in/pos-app-backend/api/v1/open/openapi.json — an OpenAPI 3 file that needs no key. Load it into Postman, Insomnia or Swagger UI. |
Authentication
Send the key on every request in either header (use one of them):
Authorization: Bearer bpk_YOUR_KEY_HERE
# or
X-API-Key: bpk_YOUR_KEY_HERE
- A key belongs to one business. All reads and writes happen inside that business. There is no way to name another business.
- A key made for one branch only sees and changes that branch's data. A key made without a branch covers the whole business.
- A read-only key can use every
GET. EveryPOST,PUTis refused with 403. - A normal sign-in token (the one the app uses) is not accepted here, and a
bpk_key is not accepted by the app. - Four things must all be true on every call: the key exists and is switched on; the shop's plan has API access (Enterprise); the owner switched API access on; you are within the rate limit. Otherwise you get one of the errors below.
Errors and limits
Every error has the same shape: { "error": "text in plain words" }. Show or log that text; it says what to do.
| Status | Message (real) | Meaning and fix |
|---|---|---|
| 401 | API key missing. Send it as "Authorization: Bearer bpk_..." or in the "X-API-Key" header. | No key was sent. Add the header. |
| 401 | This API key is not valid, or it has been switched off. | The key is wrong, was deleted, or the owner switched it off. Check you copied all of it. |
| 403 | API access is switched off for this business. Switch it on in Settings > API & Webhooks. | The owner has not switched API access on (or switched it off again). |
| 403 | API access and webhooks are part of the Enterprise plan. Upgrade your licence to use them. | The shop's plan does not include the API. |
| 403 | This API key is read-only. Create a key with write access to change data. | You used a read-only key for a write. Ask the owner for a write key. |
| 400 | items required | A required field is missing or wrong. The text names it. |
| 400 | Insufficient balance (Rs.900.00 available) | A business rule refused it (here, a gift card with too little balance). |
| 404 | Nothing with externalRef "NOPE". | Nothing found with that id or externalRef. |
| 409 | externalRef "WP-9001" is already used by product #201. | That externalRef is already attached to another record of the same kind. This is how you avoid creating the same order twice. |
| 429 | Too many requests. Please slow down (limit: 300 a minute per key). | Wait for the next minute and slow down. Spread bulk work over time. |
- Rate limit: 300 requests per minute per key, counted per clock minute. Each key has its own count.
- 5xx: a fault on our side. Try again after a few seconds. If it repeats, tell us the time and the request.
- Safe retries: a
GETcan be repeated freely. For aPOSTthat creates something, always send anexternalRef(see below). If your request times out and you are not sure whether it worked, send it again: a duplicateexternalRefreturns 409 instead of creating a second copy, and then you can read the first one with/lookup. - Sizes:
externalRefup to 120 characters;metadataup to 4000 characters (as JSON text) and must be an object.
Lists, search and paging
Every list answers with the records and the paging numbers:
HTTP 200
{
"products": [
{
"id": 201,
"name": "Web Cake 1kg",
"sku": "WEB-1",
"barcode": "601678151907",
"price": 500,
"costPrice": 300,
"taxRate": 0,
"unit": "pcs",
"category": "General",
"isActive": true,
"externalRef": "WP-9001",
"metadata": {
"shopifyId": "gid://1",
"note": "x"
},
"createdAt": "2026-11-20T07:36:07.000Z",
"updatedAt": "2026-11-20T07:36:07.000Z"
}
],
"total": 1,
"page": 1,
"limit": 2,
"pages": 1
}
| List | Filters you can send | Page size |
|---|---|---|
/products | search, categoryId, isActive, stockStatus, sortBy (default name), sortDir (asc / desc), page, limit | 20 by default |
/customers | search (name, phone, email or barcode), page, limit | set by limit |
/orders | from and to (dates, 2026-11-01), paymentMethod, paymentStatus, type, search (text to look for, such as the invoice number), page, limit | 30 by default, at most 5000 |
/coupons, /giftcards | none needed; the list is returned whole | — |
To read everything, keep asking for page=1,2,3… until page reaches pages. Prefer a moderate limit (100 or less) so a call stays fast. Because records can be added while you read, to stay in step with the shop use the webhooks and read only what changed, not the whole list every minute.
Your own ids: externalRef and metadata
Your website or system has its own numbers (a Shopify order id, an ERP customer code). Store them in BazaarPOS with the record, and find the record by them later. They work the same on products, customers, orders, coupons and gift cards.
externalRef— your id, as text (a number is turned into text). Unique within one kind of record: two products cannot share one, but a product and an order can.metadata— an object of your own notes, for example{"channel":"website","note":"gift wrap"}.- Send them when you create (
POST) or change (PUT) a record. They come back on every read, list, and webhook for that record. - Send
nullto clear one. Leave it out to keep what is there.
Find a record by your id
curl "https://www.bazaarpos.in/pos-app-backend/api/v1/open/lookup/products?externalRef=WP-9001" \
-H "Authorization: Bearer bpk_YOUR_KEY_HERE"
HTTP 200
{
"product": {
"id": 201,
"name": "Web Cake 1kg",
"sku": "WEB-1",
"barcode": "601678151907",
"price": 550,
"costPrice": 300,
"taxRate": 0,
"unit": "pcs",
"category": "General",
"isActive": true,
"inventory": {
"id": 201,
"tenantId": 1,
"storeId": 1,
"productId": 201,
"quantity": 50,
"minStockLevel": 0,
"maxStockLevel": 0,
"reorderPoint": 0,
"lastRestocked": null,
"expiryDate": null,
"syncBaseQty": null,
"batchNumber": null,
"warehouseId": null,
"defaultSupplierId": null,
"binLocation": null,
"syncId": "t1-b1-0daaa76876ec532ec1ae9e1c6b254e54",
"createdAt": "2026-11-20T07:36:07.000Z",
"updatedAt": "2026-11-20T07:36:07.000Z"
},
"externalRef": "WP-9001",
"metadata": {
"shopifyId": "gid://1",
"note": "x"
},
"createdAt": "2026-11-20T07:36:07.000Z",
"updatedAt": "2026-11-20T07:36:07.000Z"
}
}
The kind in the address is one of products, customers, orders, coupons, giftcards. Nothing found: 404 with Nothing with externalRef "NOPE".
Attach or change an id on a record that already exists
curl -X PUT "https://www.bazaarpos.in/pos-app-backend/api/v1/open/products/201/external-ref" \
-H "Authorization: Bearer bpk_YOUR_KEY_HERE" -H "Content-Type: application/json" \
-d '{"externalRef":"WP-9002","metadata":{"colour":"red"}}'
HTTP 200
{
"id": 201,
"externalRef": "WP-9002",
"metadata": {
"colour": "red"
}
}
409 and nothing is changed or created. That is on purpose: it makes "create this order" safe to repeat.Products
The things you sell. Stock is part of the product (inventory).
| Address | What it does | Needs | |
|---|---|---|---|
| GET | /products | List and search | Any key |
| GET | /products/:id | One product | Any key |
| POST | /products | Create a product | Write key |
| PUT | /products/:id | Change a product (send only what changes) | Write key |
Create
Required: name, price and costPrice (without them you get 400 "Product name is required", "Price is required" or "Cost price is required"). Useful: sku (your stock code; also a barcode is made if you send none), taxRate (percent, for example 5 or 18), unit, category, hsn, description, mrp, initialStock (the opening quantity), isActive, externalRef, metadata.
curl -X POST "https://www.bazaarpos.in/pos-app-backend/api/v1/open/products" \
-H "Authorization: Bearer bpk_YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{"name":"Web Cake 1kg","sku":"WEB-1","price":500,"costPrice":300,"taxRate":0,"unit":"pcs","initialStock":50,"externalRef":"WP-9001","metadata":{"shopifyId":"gid://1","note":"x"}}'
HTTP 201
{
"message": "Product created",
"product": {
"id": 201,
"name": "Web Cake 1kg",
"sku": "WEB-1",
"barcode": "601678151907",
"price": 500,
"costPrice": 300,
"taxRate": 0,
"unit": "pcs",
"category": "General",
"isActive": true,
"inventory": {
"id": 201,
"tenantId": 1,
"storeId": 1,
"productId": 201,
"quantity": 50,
"minStockLevel": 0,
"maxStockLevel": 0,
"reorderPoint": 0,
"lastRestocked": null,
"expiryDate": null,
"syncBaseQty": null,
"batchNumber": null,
"warehouseId": null,
"defaultSupplierId": null,
"binLocation": null,
"syncId": "t1-b1-0daaa76876ec532ec1ae9e1c6b254e54",
"createdAt": "2026-11-20T07:36:07.000Z",
"updatedAt": "2026-11-20T07:36:07.000Z"
},
"externalRef": "WP-9001",
"metadata": {
"shopifyId": "gid://1",
"note": "x"
},
"createdAt": "2026-11-20T07:36:07.000Z",
"updatedAt": "2026-11-20T07:36:07.000Z"
}
}
Change
Send only the fields to change. The reference you set earlier stays.
curl -X PUT "https://www.bazaarpos.in/pos-app-backend/api/v1/open/products/201" \
-H "Authorization: Bearer bpk_YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{"price":550}'
HTTP 200
{
"message": "Product updated",
"product": {
"id": 201,
"name": "Web Cake 1kg",
"sku": "WEB-1",
"barcode": "601678151907",
"price": 550,
"costPrice": 300,
"taxRate": 0,
"unit": "pcs",
"category": "General",
"isActive": true,
"inventory": {
"id": 201,
"tenantId": 1,
"storeId": 1,
"productId": 201,
"quantity": 50,
"minStockLevel": 0,
"maxStockLevel": 0,
"reorderPoint": 0,
"lastRestocked": null,
"expiryDate": null,
"syncBaseQty": null,
"batchNumber": null,
"warehouseId": null,
"defaultSupplierId": null,
"binLocation": null,
"syncId": "t1-b1-0daaa76876ec532ec1ae9e1c6b254e54",
"createdAt": "2026-11-20T07:36:07.000Z",
"updatedAt": "2026-11-20T07:36:07.000Z"
},
"externalRef": "WP-9001",
"metadata": {
"shopifyId": "gid://1",
"note": "x"
},
"createdAt": "2026-11-20T07:36:07.000Z",
"updatedAt": "2026-11-20T07:36:07.000Z"
}
}
Reading one (GET /products/201) returns { "product": { … } }. A product record has many more fields than shown here (for example images, tags, hsn, allergens, isSerialTracked); they are there for the shop's own screens and can be ignored. inventory holds the stock for the branch.
{"isActive": false}.Customers
People who buy from the shop. A customer is matched by phone in the shop's own screens, so send a phone number when you have one.
| Address | What it does | Needs | |
|---|---|---|---|
| GET | /customers | List and search | Any key |
| GET | /customers/:id | One customer, with purchase totals | Any key |
| POST | /customers | Create a customer | Write key |
| PUT | /customers/:id | Change a customer | Write key |
Required: name. Useful: phone, email, address, city, state, pincode, gstin, dateOfBirth, notes, creditLimit, externalRef, metadata.
curl -X POST "https://www.bazaarpos.in/pos-app-backend/api/v1/open/customers" \
-H "Authorization: Bearer bpk_YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{"name":"Web Buyer","phone":"9000011111","email":"buyer@example.com","externalRef":"CUST-77"}'
HTTP 201
{
"customer": {
"id": 151,
"name": "Web Buyer",
"phone": "9000011111",
"email": "buyer@example.com",
"address": null,
"loyaltyPoints": 0,
"creditLimit": 0,
"walletBalance": 0,
"externalRef": "CUST-77",
"metadata": null,
"createdAt": "2026-11-20T07:36:07.000Z"
}
}
Reading one customer also returns salesCount, totalSpend and lastPurchase.
Orders (bills)
An order is a bill, the same record the shop creates at the counter. An order made through the API shows in the shop's Sales screen, reports, stock and accounts like any other, and gets the next invoice number in the shop's own series.
| Address | What it does | Needs | |
|---|---|---|---|
| GET | /orders | List orders (filter by date, payment, search) | Any key |
| GET | /orders/:id | One order with its items | Any key |
| POST | /orders | Create an order | Write key |
| POST | /orders/:id/void | Cancel an order made by mistake | Write key |
| POST | /orders/:id/refund | Refund the whole order | Write key |
Create an order
| Field | Meaning |
|---|---|
items (required) | A list. Each item: productId (BazaarPOS id), quantity, price (per unit, as charged), optional discount, taxRate, name/itemName, batchId, serialNumbers. Quantity may have decimals only as far as the shop allows (for example kilograms); otherwise it is refused with a message. |
paymentMethod | CASH (default), CARD, UPI and the other methods the shop uses. For a part-credit bill leave amountPaid lower than the total. |
amountPaid | What was received. Lower than the total means the rest is on credit (udhaar) for that customer; the shop sees it in dues. |
customerId | The BazaarPOS customer. Find it first with /lookup/customers or create it. |
discount | A bill-level discount amount. |
couponCode + couponDiscount | Use a coupon. The coupon is counted as used, once, and reversed again if the order is voided or refunded. See Coupons. |
giftCardCode + giftCardAmount | Pay (part of) the bill from a gift card. The amount is taken off the card at the same moment, and put back if the order fails or is voided or refunded. |
transactionRef | The payment reference from your gateway. |
shippingAddress, placeOfSupply, isInterState, dueDate, notes, customData | Delivery and tax details, due date for credit, free notes. |
externalRef, metadata | Your own order number and notes. Always send the externalRef so a repeated call cannot create a second bill. |
curl -X POST "https://www.bazaarpos.in/pos-app-backend/api/v1/open/orders" \
-H "Authorization: Bearer bpk_YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{"items":[{"productId":201,"quantity":2,"price":550}],"paymentMethod":"CASH","amountPaid":990,"customerId":151,"couponCode":"WEB10","couponDiscount":110,"externalRef":"WEB-ORDER-5001","metadata":{"channel":"website"}}'
HTTP 201
{
"sale": {
"id": 5803,
"saleNumber": "SALE-1795160168015",
"invoiceNumber": "INV-BIZ-88888881-MAIN01-05803",
"type": "SALE",
"customerId": 151,
"subtotal": 1100,
"tax": 0,
"discount": 110,
"total": 990,
"amountPaid": 990,
"paymentMethod": "CASH",
"paymentStatus": "COMPLETED",
"createdAt": "2026-11-20T07:36:08.000Z",
"externalRef": "WEB-ORDER-5001",
"metadata": {
"channel": "website"
},
"coupon": {
"code": "WEB10",
"discount": 110
},
"giftCard": null,
"items": [
{
"id": 7783,
"productId": 201,
"name": "Web Cake 1kg",
"quantity": 2,
"price": 550,
"discount": 0,
"taxRate": 0,
"tax": 0,
"subtotal": 1100
}
]
},
"invoiceNumber": "INV-BIZ-88888881-MAIN01-05803"
}
coupon and giftCard in the answer show what this order used. A missing product, a quantity that is too precise, or a coupon or gift card that cannot be used gives 400 with the reason, and nothing is created.
Read, search
curl "https://www.bazaarpos.in/pos-app-backend/api/v1/open/orders?from=2026-11-01&to=2026-11-30&limit=2" \
-H "Authorization: Bearer bpk_YOUR_KEY_HERE"
The answer has sales (the list) with total, page, limit, pages. GET /orders/:id returns { "sale": { … } }, with items.
Payment status
paymentStatus is COMPLETED (paid in full), PENDING (not paid in full, so the rest is on credit), CANCELLED (voided) or REFUNDED. Check it before you act on a webhook.
Void and refund
Both take an optional reason. Void cancels a bill that should not have existed. Refund returns the whole bill. Both reverse a coupon or gift card the order used. A refunded bill cannot be voided, and voiding or refunding the same bill twice is refused ("Already cancelled", "Already refunded"). Partial returns (a few items back) are done in the shop's app, not through the API.
curl -X POST "https://www.bazaarpos.in/pos-app-backend/api/v1/open/orders/5804/void" \
-H "Authorization: Bearer bpk_YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{"reason":"changed my mind"}'
HTTP 200
{ "sale": { "id": 5804, "paymentStatus": "CANCELLED", … } }
curl -X POST "https://www.bazaarpos.in/pos-app-backend/api/v1/open/orders/5803/refund" \
-H "Authorization: Bearer bpk_YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{"reason":"damaged"}'
HTTP 200
{ "sale": { "id": 5803, "paymentStatus": "REFUNDED", … } }
Coupons
Discount codes. A code is stored in capital letters.
| Address | What it does | Needs | |
|---|---|---|---|
| GET | /coupons | List coupons | Any key |
| POST | /coupons | Create a coupon | Write key |
| POST | /coupons/validate | Check a code and get the discount for a total | Write key |
| GET | /coupons/:id/history | Every use of the coupon, each tied to its order | Any key |
Create
Required: code. type is PERCENT (default) or FIXED; value is the percent or the amount. Optional: description, minOrderValue, maxDiscount, maxUses, expiresAt, customerId (only that customer may use it), externalRef, metadata.
curl -X POST "https://www.bazaarpos.in/pos-app-backend/api/v1/open/coupons" \
-H "Authorization: Bearer bpk_YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{"code":"WEB10","type":"PERCENT","value":10,"externalRef":"PROMO-1"}'
HTTP 201
{
"coupon": {
"id": 1,
"tenantId": 1,
"storeId": 1,
"code": "WEB10",
"description": null,
"type": "PERCENT",
"value": 10,
"minOrderValue": 0,
"maxDiscount": null,
"maxUses": null,
"customerId": null,
"usedCount": 0,
"isActive": true,
"expiresAt": null,
"syncId": null,
"createdAt": "2026-11-20T07:36:07.000Z",
"updatedAt": "2026-11-20T07:36:07.000Z",
"externalRef": "PROMO-1",
"metadata": null
}
}
Check a code before you charge
Send the code and the order total (orderTotal, and customerId if the coupon is for one customer). It tells you whether it may be used and how much it takes off. It does not use the coupon up.
curl -X POST "https://www.bazaarpos.in/pos-app-backend/api/v1/open/coupons/validate" \
-H "Authorization: Bearer bpk_YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{"code":"WEB10","orderTotal":1100}'
HTTP 200
{
"ok": true,
"discount": 110,
"coupon": {
"id": 1,
"code": "WEB10",
"description": "10% off",
"type": "PERCENT",
"value": 10,
"customerId": null,
"externalRef": "PROMO-1",
"metadata": null
}
}
Then create the order with couponCode and couponDiscount; the coupon is counted as used at that moment. A coupon past its limit, expired, below its minimum order, or for another customer is refused with a reason.
Where it was used
HTTP 200
{
"coupon": {
"id": 1,
"code": "WEB10",
"maxUses": null,
"usedCount": 1,
"customerId": null
},
"history": [
{
"id": 1,
"saleId": 5803,
"invoiceNumber": "INV-BIZ-88888881-MAIN01-05803",
"customerId": 151,
"customerName": "Web Buyer",
"discount": 110,
"reversed": false,
"createdAt": 1795160168055
}
]
}
reversed: true means the order was voided or refunded and the use was given back.
Gift cards (vouchers)
Prepaid value with a code. Every change of balance is recorded with who, when, and which order.
| Address | What it does | Needs | |
|---|---|---|---|
| GET | /giftcards | List gift cards | Any key |
| POST | /giftcards | Issue a gift card | Write key |
| GET | /giftcards/balance?code=… | Check a balance | Any key |
| POST | /giftcards/redeem | Take an amount off the card | Write key |
| POST | /giftcards/:id/topup | Add money to the card | Write key |
| GET | /giftcards/:id/history | Every issue, use, top-up, with the balance before and after | Any key |
Issue
Required: amount (above zero). Optional: code (made for you if you send none), customerId, expiresAt, externalRef, metadata.
curl -X POST "https://www.bazaarpos.in/pos-app-backend/api/v1/open/giftcards" \
-H "Authorization: Bearer bpk_YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{"amount":1000,"code":"GC-WEB-1","externalRef":"VOUCHER-1"}'
HTTP 201
{
"giftCard": {
"id": 1,
"tenantId": 1,
"storeId": 1,
"code": "GC-WEB-1",
"initialBalance": 1000,
"balance": 1000,
"customerId": null,
"issuedBySaleId": null,
"isActive": true,
"expiresAt": null,
"syncId": "t1-b1-721de367e52b416ed2ba3185d3899b36",
"createdAt": "2026-11-20T07:36:08.000Z",
"updatedAt": "2026-11-20T07:36:08.000Z",
"externalRef": "VOUCHER-1",
"metadata": null
}
}
Check, use, top up
curl "https://www.bazaarpos.in/pos-app-backend/api/v1/open/giftcards/balance?code=GC-WEB-1" \
-H "Authorization: Bearer bpk_YOUR_KEY_HERE"
HTTP 200
{
"ok": true,
"code": "GC-WEB-1",
"balance": 1000,
"expiresAt": null
}
curl -X POST "https://www.bazaarpos.in/pos-app-backend/api/v1/open/giftcards/redeem" \
-H "Authorization: Bearer bpk_YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{"code":"GC-WEB-1","amount":300}'
HTTP 200
{
"ok": true,
"deducted": 300,
"remainingBalance": 700
}
curl -X POST "https://www.bazaarpos.in/pos-app-backend/api/v1/open/giftcards/1/topup" \
-H "Authorization: Bearer bpk_YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{"amount":200}'
HTTP 200
{
"ok": true,
"newBalance": 900
}
Taking more than the balance is refused (Insufficient balance (Rs.900.00 available)) and nothing changes. Two calls at the same moment cannot spend the same money twice: the balance is taken in one step. An expired, unknown or switched-off card is refused ("Gift card not found or inactive", "Gift card has expired", "Gift card has no remaining balance").
History
HTTP 200
{
"giftCard": {
"id": 1,
"code": "GC-WEB-1",
"initialBalance": 1000,
"balance": 900,
"expiresAt": null
},
"history": [
{
"id": 3,
"kind": "TOPUP",
"amount": 200,
"balanceBefore": 700,
"balanceAfter": 900,
"saleId": null,
"note": "Money added to the card",
"reversed": false,
"createdAt": 1795160168457
},
{
"id": 2,
"kind": "REDEEM",
"amount": 300,
"balanceBefore": 1000,
"balanceAfter": 700,
"saleId": null,
"note": null,
"reversed": false,
"createdAt": 1795160168439
},
{
"id": 1,
"kind": "ISSUE",
"amount": 1000,
"balanceBefore": 0,
"balanceAfter": 1000,
"saleId": null,
"note": "Gift card issued",
"reversed": false,
"createdAt": 1795160168398
}
]
}
kind is ISSUE, REDEEM or TOPUP. A gift card used on a bill through giftCardCode shows with that bill's saleId.
Webhooks
Instead of asking again and again, let BazaarPOS tell you. When something happens, it sends one POST with JSON to your address for each event.
What you receive
POST /your/webhook/address HTTP/1.1
Content-Type: application/json
User-Agent: BazaarPOS-Webhooks/1
X-BazaarPOS-Event: order.created
X-BazaarPOS-Event-Id: evt_iaxB2u3mrButCjUn
X-BazaarPOS-Delivery: 1
X-BazaarPOS-Signature: t=1795160086,v1=fb95a7f8a5319657eb9a24c7d26a36c58b847e33ccb93f479bc4a75f2e6efc16
{
"id": "evt_hz0-HefALM99d3TD",
"type": "order.created",
"createdAt": "2026-11-20T07:36:08.065Z",
"tenantId": 1,
"storeId": 1,
"data": {
"id": 5803,
"saleNumber": "SALE-1795160168015",
"invoiceNumber": "INV-BIZ-88888881-MAIN01-05803",
"type": "SALE",
"customerId": 151,
"subtotal": 1100,
"tax": 0,
"discount": 110,
"total": 990,
"amountPaid": 990,
"paymentMethod": "CASH",
"paymentStatus": "COMPLETED",
"createdAt": "2026-11-20T07:36:08.000Z",
"externalRef": "WEB-ORDER-5001",
"metadata": {
"channel": "website"
},
"items": [
{
"id": 7783,
"productId": 201,
"name": "Web Cake 1kg",
"quantity": 2,
"price": 550,
"discount": 0,
"taxRate": 0,
"tax": 0,
"subtotal": 1100
}
],
"…": "the same fields as the order you read through the API"
}
}
id | The event id, also in the X-BazaarPOS-Event-Id header. The same event always has the same id, even when it is sent again. Keep the ids you handled and ignore a repeat. |
type | The event name (below). |
createdAt | When the event happened (ISO time, UTC). |
tenantId, storeId | The business and the branch where it happened. |
data | The record, in the same shape the API gives, including your externalRef and metadata if you set them. |
X-BazaarPOS-Delivery | Which try this is: 1 the first time, 2 on the first retry, and so on. |
Events
| Event | When | data holds |
|---|---|---|
order.created | A bill is made, by anyone (the counter, the phone, your API call). | The order with its items, and the coupon or gift card it used. |
order.updated | A bill is voided or refunded. | The order, plus change: voided or refunded (check paymentStatus too). |
coupon.created | A coupon is made. | The coupon. |
coupon.redeemed | A coupon is used on a bill. | code, discount, orderId, invoiceNumber, customerId. |
giftcard.issued | A gift card is made. | The card with its starting balance. |
giftcard.redeemed | Money is taken off a card. | amount, previousBalance, balance, saleId. |
giftcard.balance_changed | Any change of a card's balance (use, top-up, giving back). | change (+ or −), previousBalance, balance, reason (redeemed, topped_up…). |
ping | Only when the owner presses Test. | { "message": "This is a test from BazaarPOS." } |
The events are sent for changes made in the shop's own app as well, not only through the API, so your system also learns about counter sales. Real examples:
{
"id": "evt_m3VwVeKqCmXb1jkl",
"type": "coupon.redeemed",
"createdAt": "2026-11-20T07:36:08.073Z",
"tenantId": 1,
"storeId": 1,
"data": {
"id": 1,
"code": "WEB10",
"discount": 110,
"orderId": 5803,
"invoiceNumber": "INV-BIZ-88888881-MAIN01-05803",
"customerId": 151,
"externalRef": "PROMO-1",
"metadata": null
}
}
{
"id": "evt_-nEM5dL465Pw3cFo",
"type": "giftcard.balance_changed",
"createdAt": "2026-11-20T07:36:08.433Z",
"tenantId": 1,
"storeId": 1,
"data": {
"id": 1,
"code": "GC-WEB-1",
"amount": 300,
"previousBalance": 1000,
"balance": 700,
"saleId": null,
"storeId": 1,
"change": -300,
"reason": "redeemed",
"externalRef": "VOUCHER-1",
"metadata": null
}
}
{
"id": "evt_IwpfRqSXFykwu-Uf",
"type": "order.updated",
"createdAt": "2026-11-20T07:36:08.217Z",
"tenantId": 1,
"storeId": 1,
"data": {
"id": 5804,
"invoiceNumber": "INV-BIZ-88888881-MAIN01-05804",
"paymentStatus": "CANCELLED",
"total": 550,
"change": "voided",
"…": "the rest of the order"
}
}
Check the signature
Anyone can post to your address, so check that a message really came from BazaarPOS. Each message carries X-BazaarPOS-Signature: t=<unix seconds>,v1=<hex>.
- Take the raw body exactly as received (the bytes, before you parse the JSON).
- Build the text
t + "." + rawBodyusing thetfrom the header. - Compute HMAC-SHA256 of it with the endpoint's signing secret (
whsec_…) and write it as lower-case hex. - Compare with
v1using a constant-time comparison. - Refuse the message if
tis more than 5 minutes away from your clock (this stops someone re-sending an old message).
Node.js
const crypto = require('crypto');
// Express: use express.raw({ type: 'application/json' }) on this route so req.body is the raw Buffer
app.post('/hooks/bazaarpos', express.raw({ type: 'application/json' }), (req, res) => {
const header = req.get('X-BazaarPOS-Signature') || '';
const t = (/t=(\d+)/.exec(header) || [])[1];
const v1 = (/v1=([0-9a-f]+)/.exec(header) || [])[1];
if (!t || !v1) return res.sendStatus(400);
if (Math.abs(Date.now() / 1000 - Number(t)) > 300) return res.sendStatus(400); // too old
const want = crypto.createHmac('sha256', process.env.BAZAARPOS_WEBHOOK_SECRET)
.update(t + '.' + req.body.toString('utf8')).digest('hex');
const ok = want.length === v1.length && crypto.timingSafeEqual(Buffer.from(want), Buffer.from(v1));
if (!ok) return res.sendStatus(400);
const event = JSON.parse(req.body.toString('utf8'));
// 1. if you already handled event.id, just answer 200
// 2. save it, then handle it, then answer 200 quickly
res.sendStatus(200);
});
Python (Flask)
import hmac, hashlib, os, re, time
from flask import Flask, request, abort
app = Flask(__name__)
@app.post('/hooks/bazaarpos')
def hook():
raw = request.get_data() # the raw bytes
header = request.headers.get('X-BazaarPOS-Signature', '')
t = re.search(r't=(\d+)', header)
v1 = re.search(r'v1=([0-9a-f]+)', header)
if not t or not v1 or abs(time.time() - int(t.group(1))) > 300:
abort(400)
want = hmac.new(os.environ['BAZAARPOS_WEBHOOK_SECRET'].encode(),
t.group(1).encode() + b'.' + raw, hashlib.sha256).hexdigest()
if not hmac.compare_digest(want, v1.group(1)):
abort(400)
event = request.get_json()
# ignore a repeat of event['id'], handle the event, answer quickly
return '', 200
PHP
<?php
$raw = file_get_contents('php://input');
$header = $_SERVER['HTTP_X_BAZAARPOS_SIGNATURE'] ?? '';
preg_match('/t=(\d+)/', $header, $t);
preg_match('/v1=([0-9a-f]+)/', $header, $v);
if (!$t || !$v || abs(time() - (int)$t[1]) > 300) { http_response_code(400); exit; }
$want = hash_hmac('sha256', $t[1] . '.' . $raw, getenv('BAZAARPOS_WEBHOOK_SECRET'));
if (!hash_equals($want, $v[1])) { http_response_code(400); exit; }
$event = json_decode($raw, true);
// ignore a repeat of $event['id'], handle it, answer quickly
http_response_code(200);
How delivery works, retries and the log
- Answer with any 2xx within 10 seconds. That means "received". Do the slow work afterwards, in the background.
- Anything else (an error code, a timeout, your server being down) counts as failed. We try again after 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours and 24 hours: 7 tries in all over about a day. After the last one the message is marked failed and waits for the owner's Send again button.
- Because of retries, you may receive the same event more than once, and events can arrive out of order (an
order.updatedmay come after a later event if the first try failed). Use the eventidto ignore repeats, and readpaymentStatusandcreatedAt, not the arrival order, to decide the latest state. When in doubt, read the record again with the API. - A failure of your server never affects billing. The bill is already saved; only the message waits.
- Each message is logged with its result, number of tries, the code your server answered, and the error text. The log is kept for 30 days. Open it in Settings → System & Admin → API & Webhooks → Delivery log.
- If you remove a webhook address, its waiting messages are dropped.
- Choose only the events you need on each address. An address that was not chosen for an event does not get it.
Which addresses are allowed
| Online (cloud) account | Desktop installation | |
|---|---|---|
| Protocol | https:// only | https:// or http:// |
| Where the address points | A public internet address. Addresses inside a private network (10.x, 192.168.x, 172.16–31.x, 127.x, localhost, *.local, *.internal) are refused, also if the name later turns out to point there | Any, including your own network |
| Sent from | Our servers | The shop PC itself; nothing goes through our cloud |
For development on your own laptop with an online account, use a tunnel (for example ngrok or Cloudflare Tunnel) to get a public https:// address.
Desktop installation
- The API runs on the shop PC. The address on the owner's screen is that PC's address and port. The PC must be on, and the developer's system must be able to reach it (same network, or a VPN).
- The desktop app uses its own HTTPS certificate, which your code will not trust by default. Either install that certificate on the developer's machine, or for a quick test turn certificate checking off (
curl -k). Do not leave checking off in production. - The licence is read from the shop's licence as in the cloud: the plan must include API access.
- Webhooks are sent from the PC itself, so they stop while the PC is off and resume when it is back (waiting messages are tried again; very old ones may be given up after the 7 tries).
Recipes: what developers usually build
1. Put website orders into BazaarPOS
- When your website takes an order, find or create the customer:
GET /lookup/customers?externalRef=<your customer id>; on 404,POST /customerswith the sameexternalRef. - Map each cart line to a BazaarPOS product. Keep the mapping by giving every product an
externalRef(your SKU), then/lookup/productsonce and cache the ids. POST /orderswith theexternalRefset to your order number andmetadataholding anything you want to see later. If the call times out, send it again; a 409 tells you it already exists, and/lookup/ordersgets it.- If the customer paid online, send
paymentMethod(UPIorCARD),amountPaidequal to the total, and your gateway's reference intransactionRef.
2. Keep stock and prices in step
Read products page by page into your store once, then update by PUT /products/:id when you change a price. For stock, take it from the order webhooks (order.created, and order.updated for a void or refund) and read the product's inventory when you need the exact number.
3. Sell gift cards online
- When the buyer pays,
POST /giftcardswith the amount, acodeof your own or leave it out, and your order number asexternalRef. Email the code to the buyer. - At checkout on your website,
GET /giftcards/balance?code=…to show the balance, then includegiftCardCodeandgiftCardAmountinPOST /orders. The card is charged at the same moment the order is created. - Use
giftcard.balance_changedto show customers their latest balance when they also spend it in the shop.
4. Offer a coupon code on your website
Create it once with POST /coupons (or let the shop make it in the app). At checkout, POST /coupons/validate with the cart total shows the discount; then send couponCode and couponDiscount with the order. The shop's own limits (minimum order, maximum uses, expiry, one customer) are checked for you.
5. Send every sale to your accounting or CRM system
Add a webhook address with order.created and order.updated. On each message, verify the signature, ignore a repeated event id, then write the order into your system keyed by invoiceNumber. The shop never has to do double entry.
Before you go live
- The owner has switched API access on (and Webhooks, if used), and the plan is Enterprise.
- Your key is stored on your server (an environment variable), not in code that customers can open or in a public repository.
- Every create call sends an
externalRef, so a repeat cannot double-create. - You handle
429(wait and try again) and5xx(try again with a growing wait). - Your webhook route checks the signature on the raw body, rejects old timestamps, ignores repeated event ids, and answers 2xx quickly.
- You tested with the Test button, and with one real order, one void, one gift card use.
- You do not need to poll: for live changes use webhooks; read lists only at start-up and for a nightly check.
Questions and problems
I get 401 but I copied the key.
bpk_. If the owner deleted or switched off that key, it is refused too. Make a new one.I get 403 "API access is switched off".
I get 403 about the Enterprise plan.
The API address on my screen works in a browser but my code gets an HTML page.
/ping to test it. A real answer is JSON.My order was created twice.
externalRef. Always send one. With it, the second call gets 409 and creates nothing.My webhook shows "Your server answered 404/500" or no message arrives.
The signature never matches.
t + "." + body. Make the result lower-case hex. If you rotated the secret, update your copy.I get the same event twice.
Can I delete products, customers or orders?
isActive: false and void or refund an order.