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/shopis your workspace's own shop: its one shop with no number, or its only shop./v1/commerce/credentials/{phone_number_id}/shopis the shop on one of your connected WhatsApp numbers.
The catalogue is your workspace's, shared by its shops.
Keys
| Scope | Allows |
|---|---|
products:read | read the shop, products, variants and stock |
products:write | create and change them, add images and files, move stock |
orders:read | read orders and sales |
orders:write | take 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"}'/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}'/v1/commerce/shop/productsCreate productproducts:write
nameis required.- A product has a base
priceorvariants, 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. unitis how it is sold. OnlyKGandLITERtake a fractional quantity, in steps of 0.25.- A
DIGITALproduct 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
| Status | code | When |
|---|---|---|
400 | bad_request | a catalogue rule is broken, such as a price on a product with variants |
400 | unsupported_currency | a currency other than TZS, KES, UGX or USD |
400 | too_many_images | the product already has 10 images |
404 | no_shop | there is no shop yet |
409 | shop_exists | the workspace or number already has a shop |
409 | last_variant | a product keeps at least one variant |
422 | stock_insufficient | not enough stock to take out or to sell |
422 | stock_note_required | taking stock out by hand needs a note |
All endpoints
/v1/commerce/shopPOSTCreate shop/v1/commerce/shopPATCHUpdate shop/v1/commerce/shopGETList products/v1/commerce/shop/productsPOSTCreate product/v1/commerce/shop/productsGETList top selling/v1/commerce/shop/products/top-sellingGETGet shop analytics/v1/commerce/shop/analyticsGETGet product/v1/commerce/shop/products/{product}PATCHUpdate product/v1/commerce/shop/products/{product}DELETEDelete product/v1/commerce/shop/products/{product}POSTAdd product image/v1/commerce/shop/products/{product}/imagesDELETERemove product image/v1/commerce/shop/products/{product}/imagesPOSTAdd product asset/v1/commerce/shop/products/{product}/assetPOSTAdd variant/v1/commerce/shop/products/{product}/variantsPATCHUpdate variant/v1/commerce/shop/products/{product}/variants/{variant}DELETEDelete variant/v1/commerce/shop/products/{product}/variants/{variant}GETList stock movements/v1/commerce/shop/products/{product}/stock-movementsPOSTRecord stock movement/v1/commerce/shop/products/{product}/stock-movementsGETGet product metrics/v1/commerce/shop/products/{product}/metricsGETList orders/v1/commerce/shop/ordersPOSTCreate order/v1/commerce/shop/ordersGETGet order/v1/commerce/shop/orders/{order}PATCHUpdate order/v1/commerce/shop/orders/{order}POSTPay order/v1/commerce/shop/orders/{order}/payPOSTRedeliver order/v1/commerce/shop/orders/{order}/redeliverGETGet order receipt/v1/commerce/shop/orders/{order}/receiptPOSTReissue order receipt/v1/commerce/shop/orders/{order}/receipt