Skip to content
Micup API

Referral

The referral programme links a new account to the owner of the code it registered through, as Referral describes. These routes open and close the programme, set its rules and reward tiers, deliver the rewards staff hand over by hand, and read the referrals of one account. Every route on this page requires referral:manage and records an Admin audit entry, reads included.

A value the programme cannot accept returns 400 INVALID_FORM_BODY, with one element in errors that names the field and carries an English message.

ValueDescription
same_ipThe referred account registered from, or last used, an IP address the referrer has used
ip_velocityMore accounts registered from the referred account’s registration address in 30 days than ip_registration_limit allows
same_emailThe referred account’s email address is a variant of the referrer’s
riskThe registration was risk-blocked or the referred account has a suspicious activity flag
unverifiedThe referred account’s email address was not verified within the decision window
inactiveThe referred account was not active for min_active_days days in time, or its registration still awaits approval
account_goneThe referred account, or the referrer, was deleted, banned or marked as a spammer

A referral that only waits, because its account is unverified, inactive or flagged, is checked again every day. It is rejected with that reason once 14 days have passed since its active period ended.

FieldTypeDescription
enabledbooleanWhether the programme is open
min_active_daysintegerThe days a referred account must stay active to count (1-30)
daily_valid_capintegerThe valid referrals counted for one referrer per day (1-10000)
ip_registration_limitintegerThe registrations from one address in 30 days above which a referral is not counted (1-100)

The programme starts closed, with 3 active days, a cap of 50 and an address limit of 3. The settings and tiers live in the instance configuration under the referral_config key, and no public instance route returns them.

FieldTypeDescription
idsnowflakeThe ID of the tier
thresholdintegerThe valid referrals needed to earn the tier (1-1000000)
rewardreferral tier reward objectWhat the tier gives
enabledbooleanWhether the tier grants anything new
FieldTypeDescription
settingsreferral settings objectThe programme’s rules
tiersarray[referral tier admin object]Every tier, disabled ones included
FieldTypeDescription
user_idsnowflakeThe ID of the referrer who earned the reward
tier_idsnowflakeThe ID of the tier
rewardreferral tier reward objectThe off-site reward to hand over
created_atISO8601 timestampWhen the account reached the tier
FieldTypeDescription
monthstringThe UTC month the page covers, as YYYY-MM
itemsarray[referral pending reward object]One page of rewards, oldest first
next_cursor?stringThe cursor for the next page, null on the last page
FieldTypeDescription
tier_idsnowflakeThe ID of the tier
rewardreferral tier reward objectWhat the tier gave
statusstringThe reward status
granted_atISO8601 timestampWhen the account reached the tier
delivered_at?ISO8601 timestampWhen the reward was delivered
delivered_by?snowflakeThe admin who delivered an off-site reward
note?stringThe staff note given at delivery
has_codebooleanWhether staff delivered a code with the reward. The code is never returned
FieldTypeDescription
referee_idsnowflakeThe ID of the referred account
statestringThe referral state: pending, valid or rejected
reason?stringThe rejection reason of a rejected referral, otherwise null
referred_atISO8601 timestampWhen the account registered

A deleted account stays in the list with its ID only.

FieldTypeDescription
user_idsnowflakeThe ID of the account
code?stringThe account’s referral code, null while it has none
referrer_id?snowflakeThe account that referred this account, null when none did
counts1referral counts objectThe referrals of the account by state
rewardsarray[referral user reward object]The rewards the account has earned
refereesarray[referral referee object]One page of the accounts it referred
next_cursor?stringThe cursor for the next page of referees, null on the last page

1 Read from storage, so it can trail a decision by about a minute

FieldTypeDescription
user_idsnowflakeThe ID of the referrer
tier_idsnowflakeThe ID of the tier
statusstringThe reward status, delivered after a delivery
delivered_at?ISO8601 timestampWhen the reward was delivered
has_codebooleanWhether a code was delivered
GET/v1/admin/referralAudit reason

Returns the referral admin object. It is read from storage, not from the cache the other routes use.

StatusBodyCondition
200referral admin objectThe programme was returned

The operation records one Admin audit entry with action view_referral, target type referral, target ID 0, and metadata key result_count, the number of tiers.

60 requests per minute for each authenticated user, on the admin:referral bucket.

PATCH/v1/admin/referral/settingsAudit reason

Opens or closes the programme, and sets its rules. Returns the referral admin object.

Any field of the referral settings object, each optional. An omitted field stays as it is.

Closing the programme stops new codes and new links. Referrals already pending are still decided, rewards already earned stay, and tiers still grant. To stop rewards, turn the tiers off with Update referral tier.

StatusBodyCondition
200referral admin objectThe settings were saved
400error responseA value is outside its range

The settings are saved with a compare-and-set, and every API process picks them up through the instance configuration refresh. The operation records one entry with action update_referral_settings, target type referral, target ID 0, and a <field>_old and <field>_new metadata key for every field it changed.

60 requests per minute for each authenticated user, on the admin:referral bucket.

POST/v1/admin/referral/tiersAudit reason

Adds a tier and returns the referral tier admin object. A programme holds at most 50 tiers, so reuse a disabled one past that.

FieldTypeDescription
thresholdintegerThe valid referrals needed (1-1000000)
rewardreferral tier reward objectWhat the tier gives
enabled?booleanWhether the tier grants anything new (default true)
  • A cosmetic reward must name an item with owned availability.
  • A premium_days reward is 1 through 3650 days.
  • An offsite description is 1 through 200 characters.
StatusBodyCondition
200referral tier admin objectThe tier was created
400error responseA value is refused, or the programme already holds 50 tiers

An enabled tier queues a background job that grants it to the referrers already at the threshold. The job reads one page of referrers at a time and sends no message or email. Each reward it grants records a system entry with action referral_grant, target type user, and metadata keys tier_id and reward_type, as every automatic grant does, and the job records one entry with action referral_backfill and the number granted when it ends. The operation records one entry with action create_referral_tier, target type referral_tier, the ID of the tier as target ID, and metadata keys threshold, reward_type and enabled.

60 requests per minute for each authenticated user, on the admin:referral bucket.

PATCH/v1/admin/referral/tiers/{tier_id}Audit reason

Changes the threshold of a tier, or turns it on or off, and returns the referral tier admin object. A reward never changes: give a different reward by creating a new tier and turning the old one off.

FieldTypeDescription
tier_idsnowflakeThe ID of the tier
FieldTypeDescription
threshold?integerThe valid referrals needed (1-1000000)
enabled?booleanWhether the tier grants anything new

At least one field is required. Lowering the threshold, or turning the tier on, grants it to the referrers who now reach it. Raising the threshold, or turning the tier off, takes nothing back.

StatusBodyCondition
200referral tier admin objectThe tier was saved
400error responseNo field was given, or a value is outside its range
404error responseThe tier does not exist, returned as NOT_FOUND

A tier that is on after the change, and was off or had a higher threshold before, queues the same background job as Create referral tier. The operation records one entry with action update_referral_tier, target type referral_tier, the ID of the tier as target ID, and a <field>_old and <field>_new metadata key for every field it changed.

60 requests per minute for each authenticated user, on the admin:referral bucket.

GET/v1/admin/referral/pending-rewardsAudit reason

Returns one page of the off-site rewards that staff have not delivered yet, as a referral pending rewards object. A reward belongs to the UTC month it was granted in, and the page lists that month oldest first.

FieldTypeDescription
month?stringThe UTC month as YYYY-MM (default the current month)
cursor?stringThe next_cursor of the previous page (1-200 characters)
limit?integerThe entries to return (1-100, default 50)
StatusBodyCondition
200referral pending rewards objectThe page was returned
400error responseA query value is refused

The operation records one entry with action view_referral_pending_rewards, target type referral, target ID 0, and metadata keys month and result_count.

60 requests per minute for each authenticated user, on the admin:referral bucket.

GET/v1/admin/users/{user_id}/referralsAudit reason

Returns the referral user object of an account: its code, its referrer, its counts and rewards, and one page of the accounts it referred.

FieldTypeDescription
user_idsnowflakeThe ID of the account
FieldTypeDescription
cursor?stringThe next_cursor of the previous page (1-200 characters)
limit?integerThe referred accounts to return (1-100, default 50)
StatusBodyCondition
200referral user objectThe account’s referrals were returned
400error responseA query value is refused

An account with no code and no referrals returns null code and referrer_id, zero counts, and empty rewards and referees.

The operation records one entry with action view_user_referrals, target type user, the ID of the account as target ID, and metadata key result_count, the number of referred accounts on the page.

60 requests per minute for each authenticated user, on the admin:referral bucket.

POST/v1/admin/users/{user_id}/referral-rewards/{tier_id}/deliverAudit reason

Marks an off-site reward as delivered, optionally with a code, and returns the referral reward result object. Staff hand the reward over outside the instance first, and then call this route.

FieldTypeDescription
user_idsnowflakeThe ID of the referrer who earned the reward
tier_idsnowflakeThe ID of the tier
FieldTypeDescription
code??stringA code only the referrer sees, in their own referral response (1-256 characters)
note??stringA staff note (0-500 characters)
StatusBodyCondition
200referral reward result objectThe reward was marked delivered
400error responseA value is refused
404error responseThe account has no reward for the tier, returned as NOT_FOUND
409error responseThe reward is not waiting for delivery, returned as CONFLICT

The status moves from pending_admin to delivered once, however many times the request repeats, and the reward leaves the pending list. A delivery with a code also sends the referrer a system message and an email that say the reward is ready and that name no code. A failed message or email is logged and does not fail the request.

The operation records one entry with action deliver_referral_reward, target type user, the ID of the referrer as target ID, and metadata keys tier_id, has_code and note. The entry never stores the code.

60 requests per minute for each authenticated user, on the admin:referral bucket.

POST/v1/admin/users/{user_id}/referral-rewards/{tier_id}/notifyAudit reason

Sends the referrer a system message about an off-site reward. The reward keeps its status.

FieldTypeDescription
user_idsnowflakeThe ID of the referrer who earned the reward
tier_idsnowflakeThe ID of the tier
FieldTypeDescription
contentstringThe message text (1-2000 characters)

Text that contains the code stored for the reward is refused, so a code reaches its owner only through their own referral response.

StatusBodyCondition
204noneThe message was queued
400error responseThe text is refused, or it contains the stored code
404error responseThe account has no reward for the tier, returned as NOT_FOUND
409error responseThe reward is not a pending or delivered off-site reward, returned as CONFLICT

The operation records one entry with action notify_referral_reward, target type user, the ID of the referrer as target ID, and metadata keys tier_id and content_length. The entry never stores the text.

60 requests per minute for each authenticated user, on the admin:referral bucket.