Running an online store through the API
Stock, prices and web orders for a shop on any platform, or your own site
Looped connects WooCommerce and Shopify for you, from Inventory's Online stores page (see Online stores). If your shop runs on another platform, or it's a site your developer built, you can do the same through the API: Looped keeps the stock and the prices, your site shows them, and every web order comes into Looped as a sales order for the Online Store client, with the buyer's details on it.
You'll need an API key for this. When you make it, click Online store integration under Start from and the key gets exactly what the endpoints below need. It includes inventory:settings.write so the key can make the store; take that one off afterwards if you'd rather the key couldn't change the store's settings.
Every endpoint here is in the live reference with its fields.
Make an API store
An API store sits beside any connected stores and has the same settings: when an order comes in, what it becomes, what happens when stock is short, how your tax classes map to VAT, the price list and the locations whose stock it shows.
curl https://api.looped.sh/v1/inventory/stores \
-H "X-API-Key: looped_..." \
-H "Content-Type: application/json" \
-d '{"name": "Web shop", "settings": {"priceListId": "<your retail price list>"}}'The answer has the store's id. An API store brings an order in as soon as you send it (bringInWhen is placed), because you decide when to send one. It makes a sales order and invoices it once you tell Looped it's fulfilled. The tax classes standard, zero-rated and exempt start mapped to Looped's Standard, Zero-rated and Exempt VAT; map any others with PUT /v1/inventory/stores/:id.
The store shows up on Inventory's Online stores page, where people see its orders, held orders and sync log like any other store's.
Show stock and prices
GET /v1/inventory/stock-levels answers what your product pages need, for up to 500 items at once:
curl "https://api.looped.sh/v1/inventory/stock-levels?store=<store id>&skus=SW100-NAV-M,SW100-NAV-L" \
-H "X-API-Key: looped_..."Each row has onHand, reserved (what open sales orders are still waiting for) and available, which is the number to show. With store=, it counts only the store's locations and adds price from the store's price list, with and without VAT. You can name items by skus, barcodes or ids; notFound lists anything that matched nothing.
Keep up with changes
Reading everything every few minutes gets slow once the catalogue grows. The changes feed gives you only the items whose stock moved:
- Call
GET /v1/inventory/stock-levels/changeswith no cursor. You get no rows and acursor. Keep it. - Read everything once with
/stock-levels, paging withpageandlimit. - From then on, call the feed with your cursor. You get the changed items and a new cursor. When
hasMoreis true, call again straight away.
A change shows in the feed about 30 seconds after it's saved. An item can come back when its number didn't change in the end, so treat every row as the latest value. A transaction that takes longer than 30 seconds could still slip past a cursor, so do a full read once a day as well. Price changes don't move the feed; read prices on your own schedule.
If you'd rather be told than ask, add a webhook for stock.changed.
Send an order
curl https://api.looped.sh/v1/inventory/stores/<store id>/orders \
-H "X-API-Key: looped_..." \
-H "Content-Type: application/json" \
-d '{
"externalId": "web-10423",
"number": "10423",
"status": "paid",
"buyer": { "name": "Jane Doe", "email": "jane@example.com", "phone": "+27 82 555 0100" },
"shippingAddress": { "name": "Jane Doe", "line1": "12 Long Street", "city": "Cape Town", "postalCode": "8001", "country": "ZA" },
"lines": [{ "sku": "SW100-NAV-M", "name": "Work shirt, navy, M", "quantity": 2, "unitPriceInclVat": 349 }],
"shipping": [{ "description": "Courier", "totalInclVat": 99 }],
"payment": { "gateway": "payfast", "transactionId": "pf_123" }
}'externalId is your id for the order, and it's what makes the call safe to retry. The first time answers 201 with what Looped did; every later call with the same id answers 200 and never makes a second sales order. If your client can't put the id in the body, send it as an Idempotency-Key header instead.
Amounts include VAT, in rands (or the order's currency), as a shop shows them. Looped takes the VAT out at the company's rate for standard-rated lines. A line names its item by sku or itemId. A line whose SKU no item has still comes in, flagged in unmatched, so the order isn't lost; link the SKU from the store's page in Inventory.
The answer's status says what happened:
| Status | Means |
|---|---|
imported | The sales order (or invoice) is in Looped. salesOrderId, salesOrderSerial and invoiceId say which. |
held | Held for a person: reasons says why (short of stock with the store set to hold, or a tax class with no VAT mapping). |
skipped | Not brought in yet, such as a placed order for a store set to wait until paid. |
failed | Something went wrong in Looped. Send it again; it's still one order. |
cancelled | Its sales order was cancelled. |
Moving an order on
Send the same order again with a new status as it moves along, the way a store's own webhook would:
fulfilledinvoices the sales order (when the store'screatesetting is the default) and records the payment.cancelledcancels the sales order when nothing on it is invoiced, so its stock stops being reserved.
The lines are read once. Changing them after the order is in needs a person in Looped.
There are also three direct actions, all safe to repeat:
POST /v1/inventory/stores/:id/orders/:externalId/invoiceinvoices what's left on the sales order and records the payment, whatever the store's settings say. SendpaidAtandpaymentif you have them, orrecordPayment: falseto invoice without a payment.POST .../orders/:externalId/cancelcancels it. An order that's already invoiced goes on the store's review list instead, for someone to raise a credit note.POST .../orders/:externalId/releasebrings a held order in.
The payment is recorded with the gateway's method (PayFast, Yoco, Stripe, EFT, cash, or Other) and the order number in its note, so the deposit can be matched later.
Looking after any store
These work for every store, WooCommerce and Shopify ones too, and need inventory:settings.write:
POST /v1/inventory/stores/:id/bring-in/:orderIdbrings in a held or failed order.orderIdis the order'sidonGET /v1/inventory/stores/:id/orders, not the shop's number.POST /v1/inventory/stores/:id/import-ordersimports orders the store's webhook missed:fromandto(the dates they were placed) ornumbers.POST /v1/inventory/stores/:id/resyncsends every linked item's stock and price to a WooCommerce or Shopify store again.POST /v1/inventory/stores/:id/listingslinks a store product (externalId, andvariantIdfor a variant) to an item (itemId), for an SKU onGET /v1/inventory/stores/:id/unmatched.
Permissions
| To | The key needs |
|---|---|
| Read stock, prices, stores and orders | inventory:items.read |
| Make or change a store, bring in, import or resync orders, link a product | inventory:settings.write |
| Send, cancel or release an order | inventory:items.read and invoices:quotes.write |
| Invoice an order with its payment | those, invoices:invoices.write and invoices:payments.write |
What isn't here yet
- Refunds and returns from the shop. Raise the credit note in Looped.
- Prices excluding VAT on orders.
- A feed or webhook for price changes.
- Publishing products to the shop from Looped. Your site keeps its own catalogue and reads Looped's.
Are you an AI? Visit llms.txt — these docs as plain markdown.