Vir ontwikkelaars

Connecting a shop's POS (till) to the WhatsApp marketplace

Hierdie gids is in Engels: dit is vir die programmeerders wat 'n winkel se kasregister koppel.

For developers connecting a point-of-sale system, or a script that exports from one, to a shop on the SpazaChat WhatsApp marketplace. Buyers find the shop's items in WhatsApp, order them, and collect or get them delivered. Your integration keeps the shop's items, prices and stock right, and records the WhatsApp sales in the till.

Two directions:

DirectionWhatEndpoint
Till → marketplacethe catalogue: items, prices, stockPOST /sync/items
Till → marketplacechanges as they happen: sales at the till, stock counts, pricesPOST /sync/events
Marketplace → tillWhatsApp orders the till has not recorded yetGET /sync/orders

1. Access

  • Base URL: the marketplace server's address, e.g. https://spazachat.promotefanz.com. HTTPS only.

  • Key: SpazaChat staff create one per shop and give it to you once. It looks like 12.Xy3...: the number before the dot is the shop. Send it on every request:

    X-Api-Key: 12.Xy3...

    Keep it secret: anyone with it can change the shop's stock and prices. If it leaks, ask SpazaChat staff for a new one (the old one stops working at once).

  • Answers: 401 wrong key, 403 the shop is not active (suspended or not yet approved), 422 a request that does not fit the format below (the answer says which field).

2. The catalogue: POST /sync/items

Send every item the shop sells online, or only the ones that changed. Each item is identified by your code (sku): send the same sku for the same item every time.

{
  "items": [
    {"sku": "A1", "name": "Huletts sugar", "size": "2kg", "price": "3.50", "stock": 20},
    {"sku": "B7", "name": "Bakers Inn bread", "size": "1 loaf", "price": "1.20", "stock": 15}
  ],
  "counted": false
}
Field
skuyour item code, 1 to 80 characters
nameas shoppers would recognise it; brand names are fine (the marketplace works out that Huletts is sugar)
size2kg, 500ml, 1 loaf, or ""
pricein the shop's currency: US dollars for a shop in Zimbabwe, rand for one in South Africa; more than 0, rounded to cents
stockunits in stock, a whole number, 0 or more
countedtrue only when the stock numbers come from counting the shelf (see section 5)

At most 1000 items per request: send bigger catalogues in several requests.

Answer:

{"added": 1, "updated": 1, "skipped": ["C3: plan limit 20 reached"]}
  • An item the shop already added by chat with the same name and size is taken over by your sku.

  • A shop has one item per name and size. A second sku with the same name and size as another of yours is skipped (skipped says which sku holds it): give such items different names or sizes, or one sku.

  • Renaming an item at the till renames it here on the next sync, unless another item already has that name and size: then it keeps its old name, its price and stock are still updated, and skipped says so.

  • The shop's plan limits how many items it can list: items over the limit are in skipped.

  • Once your POS manages an item, the seller can no longer change its stock or price by chat.

3. Changes: POST /sync/events

Send changes as they happen, or every few minutes in a batch. Each event has an id that you choose and never reuse (your receipt line or a UUID). An id already received is ignored, so after a timeout or an error you can simply send the whole batch again.

{
  "events": [
    {"id": "R1043-1", "type": "sale",  "sku": "A1", "qty": 2},
    {"id": "R1044-1", "type": "sale",  "sku": "A1", "qty": 1, "order_id": 381},
    {"id": "CNT-0610", "type": "stock", "sku": "B7", "stock": 12, "counted": true},
    {"id": "PRC-77",  "type": "price", "sku": "B7", "price": "1.30"}
  ]
}
typeFieldsMeaning
saleqtysold at the till: taken off the stock (never below 0)
saleorder_idthe till recorded WhatsApp order order_id (from GET /sync/orders): marked recorded, stock not taken off again
stockstock, optional countedthe till's stock for the item now (see section 5)
pricepricethe new price

At most 1000 events per request. Answer:

{"applied": 3, "duplicates": 1, "unknown_sku": [], "invalid": []}

unknown_sku: send the item with POST /sync/items first. invalid: an event missing its field, a price that is not more than 0, or an order_id that is not this shop's order for that sku (or was cancelled).

4. WhatsApp orders: GET /sync/orders

The shop's WhatsApp orders your till has not recorded yet, oldest first (cancelled ones are left out):

GET /sync/orders?after=0&limit=100
{"orders": [
  {"order_id": 381, "code": "4821", "sku": "A1", "item": "Huletts Sugar 2kg", "qty": 1,
   "unit_price": "3.50", "total": "3.50", "status": "completed", "payment_status": "paid",
   "fulfilment": "collect", "created_at": "2026-10-31T09:12:44", "completed_at": "2026-10-31T09:40:02"}
]}
status
awaiting_paymentthe buyer is paying online (EcoCash and others go to the shop, never to SpazaChat)
openpaid or cash on collection; waiting to be collected or delivered
completedhanded over to the buyer or rider: record it as a sale in the till

Record each completed order in the till, then send a sale event with its order_id (section 3): it leaves this list. To page through a long list, pass the last order_id you got as after. No buyer phone numbers or payment codes are given: the till needs the sale, not the buyer.

5. Stock: why WhatsApp orders are taken off your counts

A WhatsApp order takes its units off the marketplace's stock the moment it is placed, so two buyers cannot get the last bag of sugar. Your till does not know about it until it records the sale. So:

  • A stock number from the till is taken as the till's own count, which still includes every WhatsApp order the till has not recorded. The marketplace subtracts those orders: buyers see what is really left.

  • A sale with order_id records a WhatsApp order: it is not subtracted any more, and not taken off again.

  • A sale without order_id is a sale at the till: taken off.

  • "counted": true means someone counted the shelf. Orders already handed over are not on the shelf, so they count as recorded; only orders still waiting to be collected or delivered are subtracted.

Example: the till has 10 bags of sugar.

What happensMarketplace stock
a WhatsApp buyer orders 28
the till sends stock 10 (it does not know about the order yet)8
the buyer collects; the till records it: sale with order_id8
the till sends stock 88
a walk-in customer buys 3: sale with qty 35

If your till cannot record WhatsApp orders, never send their order_id and send counts as usual: they stay subtracted, which is right, because the till's count never lost them. A shelf count (counted: true) settles it.

6. A typical integration

Every 1 to 5 minutes:

  1. POST /sync/events with the till's sales, stock and price changes since the last run (same ids on a retry).

  2. GET /sync/orders; for each completed order not yet in the till, record the sale, then POST /sync/events with {"type": "sale", "order_id": ...}.

Once a day, or when items are added: POST /sync/items with the catalogue. After a stock-take: the counts with "counted": true.

Please send at most one request every few seconds per shop.

7. Trying it

KEY='12.Xy3...'; BASE='https://spazachat.promotefanz.com'
curl -s -X POST "$BASE/sync/items" -H "X-Api-Key: $KEY" -H 'Content-Type: application/json' \
  -d '{"items":[{"sku":"A1","name":"Huletts sugar","size":"2kg","price":"3.50","stock":20}]}'
curl -s -X POST "$BASE/sync/events" -H "X-Api-Key: $KEY" -H 'Content-Type: application/json' \
  -d '{"events":[{"id":"test-1","type":"sale","sku":"A1","qty":1}]}'
curl -s "$BASE/sync/orders" -H "X-Api-Key: $KEY"

The same in Python:

import httpx

BASE, KEY = "https://spazachat.promotefanz.com", "12.Xy3..."
api = httpx.Client(base_url=BASE, headers={"X-Api-Key": KEY}, timeout=30)

api.post("/sync/items", json={"items": [{"sku": "A1", "name": "Huletts sugar", "size": "2kg", "price": "3.50", "stock": 20}]}).raise_for_status()
for o in api.get("/sync/orders").json()["orders"]:
    if o["status"] == "completed":
        # ... record the sale in your till here ...
        api.post("/sync/events", json={"events": [{"id": f"wa-{o['order_id']}", "type": "sale",
                                                   "sku": o["sku"], "qty": o["qty"], "order_id": o["order_id"]}]}).raise_for_status()

This guide is also on the marketplace's website, at /developers/pos: send that link to anyone connecting a till.