Refport
API ReferenceTrack

Track Sale

Report a sale conversion event and attribute revenue to the referring partner for commission calculation.

POST /api/track/sale

Reports a sale event when a referred customer completes a purchase. Refport uses this to calculate the partner's commission and queue a payout.

Request

Headers

HeaderValue
AuthorizationBearer YOUR_API_KEY
Content-Typeapplication/json

Body

{
  "clickId": "abc123",
  "customerExternalId": "user_001",
  "amount": 4900,
  "currency": "usd",
  "eventName": "Purchase",
  "invoiceId": "inv_001",
  "paymentProcessor": "stripe",
  "customerEmail": "alice@example.com",
  "customerName": "Alice",
  "metadata": {
    "plan": "pro"
  }
}
FieldTypeRequiredDescription
clickIdstringYesThe refp_id click ID from the user's cookie
customerExternalIdstringYesYour internal user or customer ID
amountnumberYesSale amount in the smallest currency unit (e.g. cents for USD)
currencystringNoISO 4217 currency code — defaults to "usd"
eventNamestringNoDescriptive name for the event — defaults to "Purchase"
invoiceIdstringNoYour invoice/order ID — used for deduplication
paymentProcessorstringNoOne of stripe, shopify, polar, paddle, revenuecat, custom
customerEmailstringNoCustomer's email address
customerNamestringNoCustomer's display name
customerAvatarstringNoURL to the customer's avatar
metadataobjectNoArbitrary key-value data attached to the event

Response

200 OK

{
  "eventName": "Purchase",
  "customer": {
    "externalId": "user_001",
    "email": "alice@example.com",
    "name": "Alice"
  },
  "sale": {
    "id": "sale_xyz",
    "amount": 4900,
    "currency": "usd",
    "commissionAmount": 490,
    "status": "pending",
    "invoiceId": "inv_001",
    "paymentProcessor": "stripe"
  }
}

commissionAmount is in the same unit as amount (smallest currency unit).

Error responses

StatusCodeDescription
400INVALID_CLICK_IDThe clickId does not match any recorded click
400VALIDATION_ERRORMissing or malformed required field
401UNAUTHORIZEDInvalid or missing API key
409DUPLICATE_INVOICEA sale with this invoiceId was already recorded
429RATE_LIMIT_EXCEEDEDToo many requests — retry after backing off

Deduplication

If you pass the same invoiceId twice, the second request returns 409 Duplicate Invoice. This protects against double-counting from webhook retries or accidental duplicate calls.

SDK equivalent

await refport.track.sale({
  clickId: 'abc123',
  customerExternalId: 'user_001',
  amount: 4900,
  currency: 'usd',
  invoiceId: 'inv_001',
  paymentProcessor: 'stripe',
});

See the Node.js SDK reference for full parameter details.

On this page