Associating customers
Call /v1/referrals/associate at signup to turn a visitor into a referred customer, then review and correct referrals.
POST /v1/referrals/associate is the most important server-side call in an integration. You make it once when a customer signs up. Referalli records the facts you send, runs the attribution engine, and, if a partner earned the customer, creates a referral that later payments are matched against.
Make the call
curl -X POST https://referalli.com/v1/referrals/associate \
-H "Authorization: Bearer $KEY" \
-H "content-type: application/json" \
-d '{
"programId": "prg_...",
"customerRef": "cus_NffrFeUfNV2Hib",
"anonId": "a_k3j9x0q7m2c8v1b5n4z6",
"referralToken": "clk_01JB...",
"emailHash": "b4c9a2...",
"ip": "203.0.113.7",
"ua": "Mozilla/5.0 ...",
"idempotencyKey": "signup:usr_8812"
}'Field | Required | Description |
|---|---|---|
| yes | The program the customer is joining. |
| yes | Your id for the customer, 1 to 256 characters. Use the id your billing provider sends in its webhooks (for Stripe, the |
| no | The visitor's anonymous id from |
| no | A click id ( |
| no | A partner coupon code the customer entered. |
| no | Lowercase hex SHA-256 of the lowercased email. |
| no | The customer's IP and user agent, used only for the fingerprint fallback. |
| no | Up to 128 characters. Repeating a key returns the existing referral without recording anything new. |
| no | The customer's email domain, such as |
| no | When the signup happened (ISO 8601), for a call made late, such as one queued after an outage or a backfill. The referral, its window and attribution are dated by it. A time more than 5 minutes in the future returns |
Send whatever you have. More signals give the engine more to work with; none of the optional fields is required for a match.
The response
{
"referral": {
"id": "ref_01JB...",
"programId": "prg_...",
"partnerId": "ptr_...",
"customerRef": "cus_NffrFeUfNV2Hib",
"source": "click",
"matchedVia": "deterministic",
"confidence": 1,
"clickId": "clk_01JB...",
"linkId": "lnk_...",
"status": "active",
"ts": "2026-10-21T14:03:11.000Z",
"windowExpiresAt": "2027-10-21T14:03:11.000Z",
"touchCredits": [{ "partnerId": "ptr_...", "weight": 1, "clickId": "clk_01JB..." }],
"reasoning": { "model": "last_click", "consideredTouchpoints": 1, "windowDays": 60, "notes": [] }
}
}referralisnullwhen no partner matched. That is a normal outcome, not an error. When a partner was skipped (banned, flagged, or the customer is that partner), the response addsreasoning.notessaying so. See Partners who can't win.matchedViaiscoupon,deterministic,email_hashorprobabilistic;confidenceis 1, 1, 0.9 and 0.6 respectively. See Attribution.sourceiscouponfor coupon matches andclickotherwise.windowExpiresAtistsplus the program'ssignupToConversionDays. Payments after that date earn nothing.
Calling it more than once
A customer has at most one non-void referral per program. If one already exists, associate records the new facts and returns the existing referral unchanged: first attribution wins. Calling it for every login is safe but unnecessary.
When a referral is created, Referalli emits referral.created, records a signup conversion, and pays a signup bounty if the program's rule defines one, the referral is active, and the partner is active in your org.
Referral statuses
Status | Meaning | Earns commissions |
|---|---|---|
| Attributed and in good standing. | yes |
| Held for a person to check. Happens for fingerprint-only matches (unless the program's | no |
| Switched off by you, reversibly. Its payments are still recorded as conversions, so they count for reporting and for "first payment", but they earn nothing until it's | no |
| Cancelled, permanently. | no |
Review and correct referrals
Call | Effect | Roles |
|---|---|---|
| Referrals, newest first and paginated (the latest 500 under | any member |
| One referral, in the same shape | any member |
| Body | owner, admin |
| The referral plus every touchpoint considered: | any member |
|
| owner, admin |
| Body | owner, admin |
| Sets the status to | owner, admin |
Approving or reassigning affects payments that arrive afterwards. Commission lines already earned stay with the partner who earned them; correct those through the ledger.
Auth platforms instead of code
Whatever auth you use, Referalli can make the associate call for you: your auth server calls the signed protocol, Atlas does it natively, and Clerk, Supabase and WorkOS connect through their own user webhooks. See Auth platforms.