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

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)
  }}}

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)

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 later

8. 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

  1. Run sync: the owner's Duosell screen turns to "Connected".
  2. Send a test order without a creator coupon: it is recorded with no commission.
  3. Send the same report twice and check the second answer is duplicate.
  4. Test a cancellation and a refund on the test order.

10. Security