🤝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.
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,
});Generating referral codes
Generate 1-50 random codes (7-char alphanumeric) on behalf of a user:
import { Fuul, UserIdentifierType } from '@fuul/sdk';
const codes = await Fuul.generateReferralCodes({
user_identifier: '0x1234...',
user_identifier_type: UserIdentifierType.EvmAddress,
quantity: 5, // 1-50
max_uses: 10, // per code; omit for unlimited
});
// Returns: [{ code }, ...]Update a code's max uses
Change how many times an existing code can be used:
Check referral status
Check whether a user was referred and with which 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.
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 reference):
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.
Remove a referrer via API
To delete an admin-managed referrer-user relationship, use the DELETE /api/v1/user-referrers endpoint (API reference):
user_identifier and user_identifier_type are query parameters. The endpoint does not read a request body.
List referral relationships via API
If you mirror Fuul's referral data into your own systems, use GET /api/v1/user-referrers to read the project-wide referral bridge for incremental ingestion. Each result represents one direct (level 1) referrer-user relationship, with the upstream chain nested under referral_chain:
Response shape:
referrer_identifier / referrer_identifier_type
The direct (level 1) referrer
referral_chain.referrer_2 … referrer_4
Upstream levels 2–4, computed live at read time; null when there is no upstream referrer
rebate_rate
Rebate rate locked into the relationship (from the referral code, when present)
next_cursor
Pass back as after_id to fetch the next page; null on the last page
Query params: created_since, updated_since (ISO 8601), after_id (cursor), limit (default 500, max 1000).
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.
Admin: referral code lookup
Search and inspect referral codes across all users in your project (requires admin API key):
GET /api/v1/projects/:projectId/affiliates/referral-codes
List referral codes with optional search param — ILIKE match on code or user identifier, max 200 chars
GET /api/v1/projects/:projectId/affiliates/referral-codes/stats
Aggregated stats for referral codes
API reference
Last updated