Guides for integrators

Integration recipes

On this page

Four short, complete examples for the jobs most integrations do. Each one shows curl, JavaScript, PHP and Python. The addresses are the example store https://yourstore.example.com and the key is read from the environment: use your own. Every snippet is a starting point to adapt, not a finished product; the parts that are specific to your own system (saveOnce, openReturnCase and so on) are yours to write.

Tip

New here? Do the Quick start first. Before you connect a real store, read the Go-live checklist and Security best practices.

When a customer pays, the store sends order.paid. Your receiver checks the signature, ignores repeats, saves the event, answers 200, and a worker creates the invoice or sales order in your system. The API is your safety net: after any downtime, read what you missed.

  • A webhook for Order paid (also Order cancelled and Order refunded if your accounting follows them), made in the store's admin. See the Quick start.
  • For the catch-up: a key with read:orders.
  1. Verify the signature, then ignore a test message ("test": true) and any event you do not use.
  2. Save the event with its id in a table where the id is unique. If it is already there, do nothing: this is a repeat. Answer 200 within 5 seconds.
  3. A worker maps the order to your system: the number (text) as your reference, the items (name, size, price, quantity), and the amounts subtotal, discount, shipping and total, all in whole units of the store's currency. A gift packaging fee is already inside the total.
  4. Every hour, and after any downtime, run the catch-up: read the paid orders changed since your last successful sync, and skip order numbers you already have.
# Catch up after downtime: every paid order changed since your last successful sync.
# Follow links.next until it is null. Skip an order number you already handled.
curl -s "https://yourstore.example.com/api/v1/orders?payment_status=paid&updated_since=2026-11-21T00:00:00Z&limit=100&expand=full" \
  -H "Authorization: Bearer YOUR_API_KEY"
  • The same event can arrive more than once (retries, Redeliver). The event id is how you tell.
  • Events can arrive out of order. For money decisions you can re-read the order with GET /orders/{number} and trust its payment_status.
  • Webhooks are retried for about 45 hours and then given up on. If your receiver was down longer, the catch-up read fills the gap.
  • The customer's details are personal data. Switch off Include customers' personal details on the endpoint if your accounting does not need them.

Keep stock in step with your ERP#

Your ERP knows about deliveries, damage and counts; the store knows about sales. Push the ERP's changes through POST /inventory/adjustments. It is the only way the API changes stock, it needs a reason, and every change is written to the stock history with your key as the author.

What you need#

  • A key with write:inventory (and read:inventory to read levels). Write scopes are given by a Super Admin.
  • The ERP's item code on each size as its SKU, so you can name the size by sku.

How it works#

  1. For goods received or found, send mode: add with reason: received or found. For damaged or expired stock, mode: remove with reason: damaged or expired.
  2. After a physical count, send mode: set with the counted number and reason: correction (or other with a note).
  3. Use your ERP's document number as the Idempotency-Key, so a retry can never add the same delivery twice.
  4. To compare, read GET /inventory with updated_since: it shows on_hand, reserved and available (what the shop sells from).
# Add a delivery. The ERP document number is the Idempotency-Key, so a retry never adds twice.
curl -s -X POST "https://yourstore.example.com/api/v1/inventory/adjustments" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: erp-4471" \
  -d '{"sku": "SAMPLE-001-250", "mode": "add", "quantity": 24, "reason": "received", "note": "ERP receipt 4471"}'

# After a physical count, set the counted number.
curl -s -X POST "https://yourstore.example.com/api/v1/inventory/adjustments" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: erp-count-118" \
  -d '{"sku": "SAMPLE-001-250", "mode": "set", "quantity": 96, "reason": "correction", "note": "ERP stock count 118"}'

# Read what changed in the store since your last sync (stock levels).
curl -s "https://yourstore.example.com/api/v1/inventory?updated_since=2026-11-21T00:00:00Z&limit=100" \
  -H "Authorization: Bearer YOUR_API_KEY"

Things to handle#

  • 422 insufficient_stock: you tried to remove more than is available. Nothing was changed.
  • 409 stock_changed: you sent expected (the available stock you last saw) and it is no longer that number. Read again and decide. Nothing was changed.
  • 409 idempotency_key_reuse: the same key was used for a different request. A document number must belong to exactly one change.
  • While a customer is buying, the store's stock moves too. Prefer changes (add, remove) for ERP events, and set only for a real count.
  • Stock is never accepted when you create or update a product or a size. It changes only here.

Push products from a catalogue tool#

Create products from your catalogue or PIM tool as drafts, check them, then publish. A product made through the API starts as a draft and is published only when it is complete and you ask. Nothing is ever deleted: removing a product archives it.

What you need#

  • A key with write:products (and read:products to look products up).
  • For each product: a name and at least one size with a label, a selling price and an MRP, all as whole numbers. Add the SKU, HSN code, GST rate and a category if you have them.

How it works#

  1. Look the product up by SKU with GET /products (?sku=). If it exists, change it with PATCH /products/{id} or PATCH /products/{id}/variants/{variantId} instead of creating it again.
  2. Create it with POST /products and an Idempotency-Key built from your own product code, so a retry never creates a second product.
  3. Read meta.warnings in the answer: small points that did not stop the product from being created.
  4. Add the first stock with the stock recipe above: new sizes start at 0.
  5. Publish with PATCH /products/{id} and active: true, or send published: true when creating a product you know is complete.
# 1. Is the product there already? (a SKU is unique)
curl -s "https://yourstore.example.com/api/v1/products?sku=SAMPLE-001" -H "Authorization: Bearer YOUR_API_KEY"

# 2. Create it as a DRAFT with its sizes. Stock cannot be sent here: new sizes start at 0.
curl -s -X POST "https://yourstore.example.com/api/v1/products" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: catalogue-SAMPLE-001" \
  -d '{"name": "Sample Product", "sku": "SAMPLE-001", "short": "A short description of the product.", "variants": [{"label": "250 g", "price": 399, "mrp": 449, "sku": "SAMPLE-001-250", "weight_grams": 250}]}'

# 3. Publish it when it is complete (422 cannot_publish says what is missing, and nothing changes).
curl -s -X PATCH "https://yourstore.example.com/api/v1/products/7" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: publish-7" \
  -d '{"active": true}'

Things to handle#

  • 422 validation_failed lists each field to fix in error.fields. An HSN code must be 4, 6 or 8 digits and is never padded for you: a code that lost its leading zero is refused with the reason.
  • 422 cannot_publish means the product failed the checks for publishing (a price above zero, a price not above the MRP, no duplicate size, a valid HSN). Nothing was changed; fix the points and try again.
  • A SKU and a slug must be unique. Each size label can appear once for a product.
  • Weight is set on each size, not on the product.
  • Stock, payment and order amounts can never be sent here. See what the API will never do.

Handle a return event#

When a customer asks to send items back, or a team member enters a return, the store sends the return events. Use them to open a case in your helpdesk, expect the parcel in your warehouse, record what came back, and create the credit note when the refund is done.

What you need#

  • A webhook for the four return events: return.requested, return.approved, return.received, return.refunded.
  • Returns have to be in use in the store. Customer return requests are off until a Super Admin switches them on; returns that staff enter themselves send events too.
  • Optional: a key with read:orders to read the order a return belongs to.

How it works#

  1. return.requested: a return was asked for or entered. data has the return number, the order_number, the reason_label and the items.
  2. return.approved: the return was approved. shipping_payer says who pays to send the items back (store or customer).
  3. return.received: the items arrived. Each item has qty_received and an action: resell (back on sale) or writeoff (not sellable).
  4. return.refunded: the refund is recorded as done, with refunded_amount. It is never sent while a refund is only requested.
# A return event carries the order number. Read the order for anything else you need.
curl -s "https://yourstore.example.com/api/v1/orders/GK-261008-7WNM?expand=full" \
  -H "Authorization: Bearer YOUR_API_KEY"

Things to handle#

  • A return that is rejected, or closed without a refund, sends no event.
  • There is no API call that lists returns. Everything you need is in the event; use the order number to read the order.
  • The return number is text: RT-, the date as yymmdd, a dash and four letters or digits. Order numbers keep the store's own prefix.
  • With personal details switched off on the endpoint, the customer's email and phone in the event are masked.
  • As always, ignore repeats by event id, and ignore event types you do not know.