Developers

Integration API v1

Any website or ecommerce backend can connect to CommissionSlip. Your checkout keeps applying discounts and taking payments; your server reports completed orders and refunds so CommissionSlip can attribute them and calculate commissions. Browser-side events alone are never treated as proof of purchase.

Base URL: https://commissionslip.com/api/v1. All requests and responses are JSON. Monetary amounts are decimal strings in major units (e.g. "60.00") — floating-point numbers are rejected. A complete reference with more examples is in docs/INTEGRATION_API.md in the source repository, and the reference storefront demonstrates a full implementation.

Authentication & signing

Create an API credential under Business portal → Integrations. You receive a key id and a secret (shown once). Test-mode keys mark events as test data.

Sign every request with HMAC-SHA256:

string_to_sign = "{timestamp}.{nonce}.{METHOD}.{path_with_query}.{sha256_hex(body)}"
signature      = "v1=" + hex(hmac_sha256(secret, string_to_sign))

X-CS-Key-Id:     cs_test_pk_...
X-CS-Timestamp:  1733456789          # current Unix time (±5 minutes)
X-CS-Nonce:      q8Zr0c3vXbK2pL9mT4sW # fresh random value per attempt (16-64 chars, A-Z a-z 0-9 - _)
X-CS-Signature:  v1=4f0c...
Idempotency-Key: order-10482          # required on POST events
Content-Type:    application/json

Each signed request is accepted once (replay protection). When retrying, sign again with a new nonce and timestamp but keep the same Idempotency-Key: you'll receive the original response with the header Idempotent-Replayed: true.

# Python example
import hashlib, hmac, json, secrets, time, requests
body = json.dumps(payload).encode()
ts, nonce = str(int(time.time())), secrets.token_urlsafe(18)
path = "/api/v1/events/orders"
msg = f"{ts}.{nonce}.POST.{path}.{hashlib.sha256(body).hexdigest()}"
sig = "v1=" + hmac.new(SECRET.encode(), msg.encode(), hashlib.sha256).hexdigest()
requests.post(BASE + path, data=body, headers={"Content-Type": "application/json",
    "X-CS-Key-Id": KEY_ID, "X-CS-Timestamp": ts, "X-CS-Nonce": nonce, "X-CS-Signature": sig,
    "Idempotency-Key": f"order-{order_id}"})

Referral tracking

Promoter links look like https://commissionslip.com/r/<code>. CommissionSlip records the click and redirects to your program's destination URL with a signed cs_ref query parameter. Store it first-party (for example in a cookie, subject to your consent requirements) and send it with the order as attribution.referral_token.

POST /events/orders

{
  "external_order_id": "10482",
  "occurred_at": "2026-12-06T04:15:00Z",
  "currency": "AUD",
  "items": [
    {"sku": "TEE-01", "name": "Organic tee", "quantity": 2, "unit_price": "30.00", "discount": "0.00"}
  ],
  "order_discount": "0.00",
  "shipping": "8.00",
  "tax": "6.00",
  "total": "74.00",
  "attribution": {"referral_token": "eyJjIjo...", "discount_code": ""},
  "customer": {"email": "optional — hashed, used only for self-referral checks"}
}

Response 201 (or 200 with "status": "duplicate" if this order was already recorded):

{"data": {"status": "recorded", "external_order_id": "10482", "eligible_amount": "60.00",
  "attribution": {"method": "referral", "affiliate_id": "K7M2Q9XA"},
  "commission": {"slip_number": "CS-2612-000042", "status": "pending", "gross_amount": "9.00",
                 "net_amount": "9.00", "rate_percent": "15", "currency": "AUD"}},
 "request_id": "..."}

Sending the same external_order_id again never creates another commission. Sending it with different details returns 409 order_conflict; report changes as refunds.

POST /events/refunds

{"external_refund_id": "R-551", "external_order_id": "10482", "occurred_at": "2026-12-08T01:00:00Z",
 "currency": "AUD", "amount": "20.00", "full_refund": false, "reason": "Returned one item"}

amount is the refunded eligible merchandise value (excluding tax and shipping). Use "full_refund": true to reverse the whole commission. Refunds are idempotent by external_refund_id; refunds received before their order are held and applied when the order arrives. Commissions are recalculated from the cumulative refunded amount, so the result does not depend on delivery order.

POST /events/clicks

If visitors land on your site via your own URLs (e.g. ?ref=K7M2Q9XA), report the visit server-side to obtain a referral token:

{"affiliate_id": "K7M2Q9XA", "landing_url": "https://shop.example/?ref=K7M2Q9XA"}
→ {"data": {"status": "recorded", "referral_token": "...", "expires_at": "...", "attribution_days": 30}}

GET /codes/validate?code=ALEX7K2M

{"data": {"code": "ALEX7K2M", "valid": true, "discount": {"type": "percentage", "value": "10.00", "currency": "AUD"},
          "program": "acme-ambassadors"}}

Your checkout applies the discount. Include the code in attribution.discount_code when reporting the order.

GET /integration/status · GET /orders/{external_order_id}

Check connectivity and credential mode, and look up an order's attribution and commission status for reconciliation.

Errors

{"error": {"code": "validation_error", "message": "Request validation failed.",
           "details": {"items[0].unit_price": "This field is required."}}, "request_id": "..."}

Codes include missing_authentication, invalid_credentials, invalid_nonce, invalid_signature, timestamp_out_of_range, replayed_request (409), idempotency_key_required, idempotency_key_reused (422), validation_error, order_conflict (409), refund_conflict (409), rate_limited (429) and processing_error (500 — safe to retry with the same Idempotency-Key).

Attribution & calculation policy

  • A valid, active affiliate discount code takes priority over a referral token.
  • A referral token credits the promoter only within the program's attribution window.
  • Default basis: eligible merchandise revenue after discounts, excluding tax and shipping. Order-level discounts are allocated pro rata across lines.
  • Lines with "commission_eligible": false and SKUs excluded by the program earn no commission.
  • Commission rates are snapshotted per order; later rate changes never alter past commissions.