Connect your own sales channel
Sell on a website or marketplace O2M has no connector for, with stock and orders in step.
Overview
This guide connects a sales channel O2M has no connector for. O2M holds the stock and ships the orders, and your channel stays in step.
What you will build
Customer orders
on your channel
POST /orders
O2M reserves stock
stock.changed
you update your channel
Warehouse ships
as for any order
shipment.dispatched
you tell the customer
You need a key with Read stock, movements, warehouses and shipments, Read orders and Create and cancel orders, and a webhook address with stock.changed, shipment.dispatched and order.status_changed.
Send your orders
When a customer orders, send it to O2M under a channel name of your own. This name then appears on the order in O2M and in reports.
curl -X POST "https://api.o2m.in/api/v1/orders" \
-H "X-Access-Key: $O2M_ACCESS_KEY" \
-H "X-Secret-Key: $O2M_SECRET_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-SO-1001" \
-d '{
"order_id": "SO-1001",
"channel": "mysite",
"ordered_at": "2026-10-02T10:00:00Z",
"payment_method": "prepaid",
"customer": {
"name": "Ravi",
"email": "ravi@example.com"
},
"shipping_address": {
"name": "Ravi",
"phone": "9800000000",
"address1": "12 MG Road",
"city": "Pune",
"state": "Maharashtra",
"pincode": "411001"
},
"taxes_included": true,
"lines": [
{
"sku": "MUG-BLUE",
"quantity": 2,
"unit_price": 100,
"tax": 30.51
}
]
}'Keep the id from the answer. If the connection fails, send the same request again: the same order_id never makes a second order.
Keep your stock in step
When stock.changed arrives, set your channel's quantity to sellable.
function handle(event) {
if (event.event === "stock.changed") {
myChannel.setQuantity(event.data.sku, event.data.sellable);
}
}Do a full check once a day with List stock so that a missed event cannot leave a number wrong for long.
Tell your customer
| Event | What to do |
|---|---|
shipment.dispatched | Send the customer courier and awb. |
order.status_changed to delivered | Mark the order delivered. |
order.status_changed to returned | Start your refund. |
Cancel an order
If the customer cancels before dispatch, cancel the order in O2M so its units go back on sale. Once it has shipped, this answers 409, and you handle it as a return.