🀝Referral Codes

Referral codes let projects create shareable codes for their users. When a user accepts a referral code, a permanent referrer-user relationship is created. The SDK provides methods to list, generate, check, use, and delete referral codes.

Referral codes are generated by the project on behalf of users β€” they are auto-generated (random 7-char alphanumeric) and scoped to a single project. Affiliate codes can also be activated as referral codes within a project.

circle-info

Referral codes are different from affiliate codes. Affiliate codes are custom, created by the affiliate with a wallet signature, and embedded in tracking links (?af=code) for automatic attribution. Referral codes are project-generated and require the user to explicitly accept the code.

For a full comparison, see Affiliate Codes vs Referral Codes.

List a user's referral codes

import { Fuul, UserIdentifierType } from '@fuul/sdk';

const result = await Fuul.listUserReferralCodes({
  user_identifier: '0x1234...',
  user_identifier_type: UserIdentifierType.EvmAddress,
});

Check referral status

Check whether a user was referred and with which code:

const status = await Fuul.getReferralStatus({
  user_identifier: '0x1234...',
  user_identifier_type: UserIdentifierType.EvmAddress,
});

if (status.referred) {
  console.log('User was referred with code:', status.code);
}

Check if a code is available

Accept a referral code

When a user accepts a referral code, a permanent referrer-user relationship is created β€” all future conversions by this user will be attributed to the referrer.

circle-info

The signed message must follow this exact format: I am using invite code ${code}

Note: the signature says "invite code" for legacy reasons β€” this applies to all referral codes, regardless of how your project uses them.

Requiring a signature ensures event validity and prevents fraud. This is mandatory.

Set a referrer via API

If you manage your own referral system (e.g. a fintech or exchange with existing user relationships), you can create or update referrer-referee relationships directly through the API instead of using referral codes (API referencearrow-up-right):

If you include a referral_code, the code is validated and its rebate rate is locked into the relationship. The response includes a referral_code_id you can use to trace which code established the referral.

circle-info

This endpoint requires a service_role API key. If the user already has a referrer, the existing relationship is overwritten.

Get user referrer

Get the current referrer for a specific user:

Delete a referral

Allows users to remove a referral relationship they have, freeing up a use on the referral code. The referral code's usage count will be incremented by one.

The signed message must follow this format:

I am deleting referral for user ${user_identifier} from code ${code}

Resolving email recipients

When payouts are created for email identifiers but no wallet address is mapped yet, they remain in a "pending resolution" state. Use these endpoints to check for unresolved payouts and create email-to-address mappings so the rewards can be claimed.

List emails with pending unresolved payouts (API referencearrow-up-right):

Create mappings to resolve pending payouts to wallet addresses (API referencearrow-up-right):

circle-info

Once a mapping is created, pending movements for that email are asynchronously resolved to the target address. You can send up to 100 mappings per request.

API reference

Feature
API endpoint
Reference

List user's codes

GET /v1/referral-codes

Generate codes

POST /v1/referral-codes

Check code availability

GET /v1/referral-codes/{code}

Update code

PATCH /v1/referral-codes/{code}

Check referral status

GET /v1/referral-codes/status

Use referral code

PATCH /v1/referral-codes/{code}/use

Delete referral

DELETE /v1/referral-codes/{code}/referrals

Set referrer via API

PUT /v1/user-referrers

Get user referrer

GET /v1/user/referrer

Last updated