Invite Rewards

Invite Rewards

One endpoint here takes an API token: attribution, which reports who invited a new member. The rest are the public endpoints behind /invite/<slug> — they authenticate the visitor with a Discord cookie, not a Bearer token.

Attribute a join

POST
https://api.envyauth.my.id/api/v3/projects/:project_uuid/invites/attribute

Records that a freshly-joined member came in through a specific invite code. This is what the Discord bot calls after resolving its join diff.

terminal
curl -X POST https://api.envyauth.my.id/api/v3/projects/<project_uuid>/invites/attribute \  -H "Authorization: Bearer YOUR_API_TOKEN" \  -H "Content-Type: application/json" \  -d '{"invitee_discord_id":"1118453649727823974","invite_code":"7hncts"}'
FieldTypeRequiredMeaning
invitee_discord_idstringyes17–20 digit Discord snowflake of the member who joined.
invite_codestringyesThe invite code they used, 1–32 characters.

The inviter is not a parameter. It's resolved server-side from the invite code, so a caller can never credit an arbitrary account.

json
{  "success": true,  "data": { "attributed": true },  "requestid": "uuid"}

A join that doesn't qualify is still a 200 with attributed: false and a reason, so the bot never retries a legitimately-skipped join.

ReasonMeaning
disabledThe project has no active invite program.
untracked_inviteThe code isn't a tracked personal invite for this project.
self_inviteThe invitee and the inviter are the same account.
account_too_newThe invitee's Discord account is younger than the configured minimum.
already_memberThe invitee already holds a key in this project.

When the program's qualify mode is join, a successful attribution pays out immediately. redeem and redeem_exec leave it pending until their own trigger fires.

StatusCodeMeaning
404NOT_FOUNDThe project doesn't belong to this token's account.
400BAD_REQUESTMissing JSON content type or unparseable body.
422VALIDATIONBad snowflake or invite code.

Public endpoints

The endpoints below back the public /invite/<slug> page. They take a token query parameter — the program's slug_token — and identify the visitor from their Discord cookie. All are rate-limited per IP, and the write endpoints are additionally throttled per Discord identity.

A missing or disabled program returns 404 with code: "NOT_FOUND" on every one of them.

Program info

GET
https://api.envyauth.my.id/api/v3/invites/s/:slug_token

The public, non-secret slice of the config: rules text, reward terms, caps, and the economy settings. It never exposes the project UUID or owner internals.

json
{  "success": true,  "data": {    "config": {      "slug":            "atomic-hub",      "enabled":         true,      "project_name":    "Atomic Hub",      "qualify_mode":    "redeem",      "reward_type":     "points",      "reward_amount":   3,      "per_inviter_cap": 30,      "min_invitee_account_age_days": 7,      "milestones":      [{ "count": 5, "bonus": 10 }],      "rules_text":      "One invite counts once the friend redeems a key.",      "reward_currency": "points",      "rate_per_invite": 1,      "points_per_unit": 1,      "budget_exhausted": false    }  },  "requestid": "uuid"}

budget_exhausted means the owner's budget cap is spent and new earns are paused until they top it up.

Visitor progress

GET
https://api.envyauth.my.id/api/v3/invites/me?token=:slug_token

The signed-in visitor's identity, progress, wallet, and existing invite link.

Without a visitor cookie this still returns 200, with authed: false and the config only, so the page can render its sign-in state.

json
{  "success": true,  "data": {    "authed":  true,    "visitor": { "discord_id": "…", "username": "someone", "avatar": "…" },    "config":  { },    "progress": {      "qualified":     21,      "pending":       3,      "reward_earned": 147,      "reward_unit":   "points",      "cap":           30    },    "wallet": {      "balance":         42,      "lifetime_earned": 147,      "currency":        "points",      "matured":         42    },    "invite":   { "code": "7hncts", "url": "https://discord.gg/7hncts" },    "page_url": "https://envyauth.my.id/invite/atomic-hub"  },  "requestid": "uuid"}

wallet is null for programs that don't use points or cash. For a cash program, matured is the portion that has cleared the maturation hold and can actually be withdrawn.

POST
https://api.envyauth.my.id/api/v3/invites/link?token=:slug_token

Returns the visitor's personal Discord invite, creating it on first call and reusing it afterwards so the link stays stable.

json
{  "success": true,  "data": { "code": "7hncts", "url": "https://discord.gg/7hncts" },  "requestid": "uuid"}
StatusCodeMeaning
401UNAUTHORIZEDNo Discord visitor cookie.
409NOT_CONFIGUREDNo guild linked, or no channel to mint the invite against.
502INVITE_FAILEDDiscord refused — the bot is missing Create Invite on the server.

Redeem points

POST
https://api.envyauth.my.id/api/v3/invites/wallet/redeem?token=:slug_token

Spends points from the visitor's wallet into the owner-configured reward. Only valid when the program's reward type is points.

terminal
curl -X POST "https://api.envyauth.my.id/api/v3/invites/wallet/redeem?token=<slug_token>" \  -H "Content-Type: application/json" \  -d '{"units":3}'
FieldTypeRequiredMeaning
unitsintegeryesHow many units of the redeem reward to buy, 1–100,000. Cost is units × points_per_unit.
json
{  "success": true,  "data": {    "redeem_type":  "whitelist_days",    "units":        3,    "spent":        3,    "balance":      39,    "applied_days": 3  },  "requestid": "uuid"}

The balance decrement and the reward application happen in one atomic step. A Discord-role redemption is assigned by the bot right after the balance clears.

StatusCodeMeaning
401UNAUTHORIZEDNo Discord visitor cookie.
409NOT_REDEEMABLEThis program doesn't use redeemable points.
409INSUFFICIENTNot enough points for that redemption.

Request a cash payout

POST
https://api.envyauth.my.id/api/v3/invites/payout/request?token=:slug_token

Reserves a payout from the visitor's matured balance. Only valid on a cash program with payouts enabled.

terminal
curl -X POST "https://api.envyauth.my.id/api/v3/invites/payout/request?token=<slug_token>" \  -H "Content-Type: application/json" \  -d '{"amount":50000}'
FieldTypeRequiredMeaning
amountintegeryesAmount in minor units, 1–1,000,000,000.
json
{  "success": true,  "data": { "payout_id": "uuid", "amount": 50000, "balance": 12000 },  "requestid": "uuid"}
StatusCodeMeaning
401UNAUTHORIZEDNo Discord visitor cookie.
409PAYOUT_DISABLEDNot a cash program, or payouts are switched off.
409NOT_MATUREDThat amount hasn't cleared the maturation hold yet.
409BELOW_THRESHOLDBelow the program's minimum payout.

Leaderboard

GET
https://api.envyauth.my.id/api/v3/invites/leaderboard?token=:slug_token

Top 10 inviters by qualified-invite count. No auth needed, but the caller's own row is marked when a visitor cookie is present.

json
{  "success": true,  "data": {    "currency":    "points",    "reward_type": "points",    "entries": [      {        "rank":            1,        "username":        "someone",        "avatar_url":      "…",        "qualified_count": 21,        "lifetime_earned": 147,        "is_you":          false      }    ]  },  "requestid": "uuid"}

Ranking uses lifetime_earned, which never decreases, so spending points or cashing out doesn't cost anyone their position. Usernames resolve from the project's whitelist rows; an unresolved inviter falls back to a shortened id.