BIO.RE
Referral

Track Referral Click

Public endpoint. Increments the click counter on a ReferralLink. Silent on missing/inactive codes — the request never fails.

POST /api/v1/referral/click/:code — 🌐 Public · Rate limit: 60 req / minute · Kill-switched

Increments the clicks counter on the ReferralLink row matching code. Public — no auth required (clicks come from landing pages where the visitor isn't signed in yet). Silent on missing/inactive codes: if the code doesn't exist, the database update fails internally, the failure is logged at warn level, and the response is still 200 OK.

Always returns tracked: true. Whether the code matched or not, the response shape is identical. This is intentional — landing pages call this from JavaScript and shouldn't block on tracking failures. The server logs the failure for observability.

Click counter is best-effort, not auditable. The clicks increment is unguarded — no duplicate suppression, no IP tracking, no bot filtering. For the actual referral attribution chain, the platform records signups (in recordSignup) and conversions (in commission-paid flows) which are tied to authenticated user creation, not click events.

Request

Path parameters

ParamTypeNotes
codestringThe referral code (no UUID pipe — raw string)

No body, no headers required.

Response

200 OKApiResponseOf<TrackClickResponseDto>

{
  "success": true,
  "data": {
    "tracked": true
  }
}
FieldTypeNotes
trackedbooleanAlways true on 200 — even if the code doesn't exist (silent failure path)

Errors

HTTPcode / i18nKeyReason
429(throttle)Rate limit exceeded (60 req/min)
503features.referral_disabledAdmin kill switch REFERRAL is active

The endpoint does not return 4xx for missing codes — see callout.

Side effects

  1. prisma.referralLink.update({ where: { code }, data: { clicks: { increment: 1 } } }).
  2. .catch()-d to a warn log on failure (e.g. unknown code, DB transient issue). Failure does NOT propagate.
  3. Return { tracked: true }.

Code samples

curl -X POST https://api.bio.re/api/v1/referral/click/alice123
async function trackReferralClick(code: string): Promise<void> {
  // Fire-and-forget — landing page navigation should never block on this
  await fetch(`https://api.bio.re/api/v1/referral/click/${encodeURIComponent(code)}`, {
    method: 'POST',
  }).catch(() => { /* swallow — analytics is non-critical */ });
}
<!-- /ref/[code]/page.tsx (Next.js) -->
<script>
  // Extract code from URL: /ref/alice123 → 'alice123'
  const code = window.location.pathname.split('/').filter(Boolean).pop();
  if (code) {
    fetch(`/api/v1/referral/click/${code}`, { method: 'POST' }).catch(() => {});
  }
</script>

Try it

POST
/api/v1/referral/click/{code}

Path Parameters

code*string

Response Body

application/json

curl -X POST "https://loading/api/v1/referral/click/string"
{
  "success": true,
  "data": {
    "tracked": true
  }
}

Source

SourcePathLines
Controllerapps/api-core/src/modules/referral/referral.controller.ts49–56 (trackClick)
DTO (response)apps/api-core/src/modules/referral/dto/referral-response.dto.ts311–314 (TrackClickResponseDto)
Serviceapps/api-core/src/modules/referral/referral.service.ts49–53 (trackClick)
Prisma modelpackages/prisma/prisma/schema.prismaReferralLink.clicks (counter)

On this page