Commerce

Shop and catalogue

Open a shop on WhatsApp, list your products and keep their stock.

A shop sells on a WhatsApp number. Your integration manages its catalogue, stock and orders through the API, and your customers buy in the chat.

Which shop

  • /v1/commerce/shop is your workspace's own shop: its one shop with no number, or its only shop.
  • /v1/commerce/credentials/{phone_number_id}/shop is the shop on one of your connected WhatsApp numbers.

The catalogue is your workspace's, shared by its shops.

Keys

ScopeAllows
products:readread the shop, products, variants and stock
products:writecreate and change them, add images and files, move stock
orders:readread orders and sales
orders:writetake orders and move them along their statuses

A test key only reads.

Open the shop

curl https://v3.ghala.io/v1/commerce/shop \
  -H "Authorization: Bearer $GHALA_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "Pwani Foods", "currency": "TZS"}'
POST/v1/commerce/shopCreate shopproducts:write

Every field is optional. currency is TZS, KES, UGX or USD. Until there is a shop, reading it answers 404 no_shop.

Add a product

curl https://v3.ghala.io/v1/commerce/shop/products \
  -H "Authorization: Bearer $GHALA_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "Mango juice 1L", "price": 3500, "stock": 120}'
POST/v1/commerce/shop/productsCreate productproducts:write
  • name is required.
  • A product has a base price or variants, never both. Adding the first variant turns a priced product into a variant one, and a product keeps at least one variant.
  • Prices are whole numbers up to 100,000,000, and come back as strings such as "3500.00". Stock goes up to 1,000,000.
  • unit is how it is sold. Only KG and LITER take a fractional quantity, in steps of 0.25.
  • A DIGITAL product is one priced file, with no variants and no stock.
  • Up to 7 tags, lowercased, 15 characters each.
  • Deleting a product or variant that has sold archives or deactivates it instead.

Images are uploaded as a multipart file, JPEG or PNG, up to 10 MB and 10 per product.

List products

GET/v1/commerce/shop/productsList productsproducts:read

Newest first, as {"items": [...], "next_cursor": "...", "has_more": true}. limit is 1 to 100, 25 when you leave it out. Archived products show only with status=ARCHIVED.

Keep stock right

Every stock change, by an order, by hand or by editing the number, is a stock movement. To record one by hand:

POST/v1/commerce/shop/products/{product}/stock-movementsRecord stock movementproducts:write

Send direction, quantity and, for a variant, variant_id. Taking stock out by hand needs a note.

When it fails

StatuscodeWhen
400bad_requesta catalogue rule is broken, such as a price on a product with variants
400unsupported_currencya currency other than TZS, KES, UGX or USD
400too_many_imagesthe product already has 10 images
404no_shopthere is no shop yet
409shop_existsthe workspace or number already has a shop
409last_varianta product keeps at least one variant
422stock_insufficientnot enough stock to take out or to sell
422stock_note_requiredtaking stock out by hand needs a note

All endpoints

On this page