POST /api/track/sale

Record a successful sale. Creates a pending commission for the attributed partner.

Endpoint

POST https://partli.app/api/track/sale

Headers

Authorization: Bearer pk_live_...
Content-Type: application/json

Body

{
  "externalId": "inv_abc123",            // required, dedupe key (your invoice/order id)
  "customerExternalId": "cus_xyz",       // required, your customer id
  "amountCents": 4900,                   // required, sale amount in cents
  "currency": "USD",                     // optional, default "USD"
  "clickId": "c_aB3xY9ZqLp",             // optional, required for attribution
  "eventName": "subscription_paid",      // optional, default "sale"
  "metadata": { "plan": "starter" }      // optional, free-form jsonb
}

Response

{
  "eventId": "uuid-of-event",  // null if not attributed
  "attributed": true
}

Reward resolution

  1. If partner is in a group with a sale reward → use the group reward
  2. Otherwise → fall back to the program's default reward
  3. For one-time interval: skip if a prior commission exists for this customer
  4. For recurring: skip if past rewardDurationMonths

cURL example

curl https://partli.app/api/track/sale \
  -X POST \
  -H "Authorization: Bearer pk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "externalId": "inv_abc123",
    "customerExternalId": "cus_xyz",
    "amountCents": 4900,
    "clickId": "c_aB3xY9ZqLp"
  }'

Errors

  • 401 Unauthorized — bad API key
  • 400 Bad Request — invalid body or amountCents < 1

Re-posting the same externalId is a silent no-op (returns the original event id) — safe to retry.