Duosell API: developer guide
Connect a custom site to Duosell: signed reports of orders, cancellations, refunds and products – the same interface the WooCommerce plugin uses.
A signature proves the report came from the store's site unchanged. It does not verify the transaction with the payment provider. Commissions come only from order reports, never from a visit or click alone.
1. Connection key
- The store owner creates a key in Duosell: Connect store → "I have a developer".
- Format: lk_<connection id, 32 chars>_<secret>. The id goes in a header; the secret only signs and is never sent.
- Keep the key server-side only (e.g. an environment variable), never in browser code.
2. Every request
POST with a JSON body and three headers:
POST https://ycuvcpslvkgndytubycn.supabase.co/functions/v1/woo Content-Type: application/json X-LinkUp-Connection: <connection_id> X-LinkUp-Timestamp: <unix seconds> X-LinkUp-Signature: hex( HMAC-SHA256( secret, "<timestamp>.<raw body>" ) )
Signatures are valid for 5 minutes around server time, so keep your server clock in sync.
3. Connection check and coupons (sync)
The first call marks the site as connected in Duosell. The answer lists the creator coupons that should be active on your site; call it hourly and create, enable or disable coupons accordingly.
{"action":"sync","plugin_version":"my-site 1.0"}
→ 200 {"ok":true,"result":{"server_time":"…","coupons":[{"code":"NOA10","discount_pct":10,"active":true}]}}4. Order report (event)
Send a report on every order change (created, paid, completed, cancelled, refunded) with the full order state at that moment.
{"action":"event","event":{
"event_id": "order-1042-v3", // unique per change; the same id twice is ignored
"type": "order.upserted",
"occurred_at": "2026-11-11T09:30:00Z",
"order": {
"id": "1042", // your order id (unique in your store)
"status": "completed", // pending | processing | on-hold | completed | cancelled | refunded | failed
"currency": "ILS",
"total": 24600, // minor units (agorot), incl. VAT and shipping
"tax": 0, "shipping": 1000, "shipping_tax": 0,
"coupons": ["NOA10"],
"ref": "NOA10|1762851000", // optional: lku value + visit time (see below)
"email_hash": "<sha256 of lower-case e-mail>", // optional, only to detect self-referrals
"created_at": "2026-11-11T09:20:00Z",
"refunds": [{"id":"r1","amount":5900}] // every refund so far (send the full list each time)
}}}- All amounts in minor units (agorot), integers.
- event_id is unique per change; the same event_id twice is processed once.
- Orders are identified by id; a new report for the same order updates it, never duplicates it.
- If prices include VAT and you have no tax breakdown, send tax: 0 and Duosell deducts VAT per the store's setting.
- Cancellation: status "cancelled". Refund: add it to refunds. The commission updates automatically.
- A commission is approved only after the store's refund window.
5. Products (products, optional)
Product sync lets creators choose what to promote. Prices in minor units.
{"action":"products","products":[
{"id":"88","name":"Silver ring","url":"https://shop.example/p/88","image":"https://…/88.jpg",
"price":24900,"currency":"ILS","in_stock":true,"stock_qty":12,"categories":["Rings"],"status":"publish"}]}6. Link attribution (optional)
- A creator link reaches your site with lku=CODE.
- Keep the code and visit time (seconds) in a first-party cookie for 30 days, subject to cookie consent.
- On the order, send ref as CODE|unix-seconds. A coupon wins over a link.
7. Responses
200 {"ok":true,...} accepted
401 {"error":"unauthorized"} wrong signature, id or clock
422 {"error":"invalid_event" | "connection_disconnected"} do not retry
503 {"error":"temporary_error"} retry later8. Examples
// Node.js 18+
import crypto from "node:crypto";
const [, id, secret] = process.env.LINKUP_KEY.match(/^lk_([0-9a-f]{32})_(.+)$/);
async function linkup(body) {
const raw = JSON.stringify(body), ts = Math.floor(Date.now() / 1000);
const sig = crypto.createHmac("sha256", secret).update(`${ts}.${raw}`).digest("hex");
const r = await fetch("https://ycuvcpslvkgndytubycn.supabase.co/functions/v1/woo", { method: "POST", body: raw, headers: {
"Content-Type": "application/json", "X-LinkUp-Connection": id, "X-LinkUp-Timestamp": String(ts), "X-LinkUp-Signature": sig } });
return r.json();
}
await linkup({ action: "sync", plugin_version: "my-site 1.0" }); // connection check<?php // PHP 7.4+
preg_match('/^lk_([0-9a-f]{32})_(.+)$/', getenv('LINKUP_KEY'), $m);
$raw = json_encode(['action' => 'sync', 'plugin_version' => 'my-site 1.0']);
$ts = time();
$sig = hash_hmac('sha256', $ts . '.' . $raw, $m[2]);
$ch = curl_init('https://ycuvcpslvkgndytubycn.supabase.co/functions/v1/woo');
curl_setopt_array($ch, [CURLOPT_POST => true, CURLOPT_POSTFIELDS => $raw, CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json', "X-LinkUp-Connection: {$m[1]}", "X-LinkUp-Timestamp: $ts", "X-LinkUp-Signature: $sig"]]);
echo curl_exec($ch);9. Before going live
- Run sync: the owner's Duosell screen turns to "Connected".
- Send a test order without a creator coupon: it is recorded with no commission.
- Send the same report twice and check the second answer is duplicate.
- Test a cancellation and a refund on the test order.
10. Security
- If the key leaks, the owner creates a new one in Duosell and the old one stops working at once.
- Disconnecting the store in Duosell blocks further reports (connection_disconnected).
- Never send customer names, addresses, phone numbers or payment details.
