Referrals
Referral / promo codes with JSONB rewards for both referrer and referee.
Referral codes live on the tenant DB with nullable app_user_id (admin-created promo codes have app_user_id = NULL; user-owned codes are created via /client/referrals/my-code). Claims are logged in referral_claims.
Source: apps/api/src/routes/admin/referrals.ts.
Endpoints
| Method | Path | Description |
|---|---|---|
| POST | /admin/projects/:projectId/referrals | Create a promo code (admin-owned). |
| GET | /admin/projects/:projectId/referrals | List codes. |
| GET | /admin/projects/:projectId/referrals/:codeId/stats | Stats + all claims for a code. |
| PATCH | /admin/projects/:projectId/referrals/:codeId | Partial update. |
| DELETE | /admin/projects/:projectId/referrals/:codeId | Delete. |
POST /admin/projects/:projectId/referrals
Request (CreateReferralProgramInput)
| Field | Type | Required | Description |
|---|---|---|---|
code | string | no | Auto-generated via @amba/shared/referral-codes if omitted. |
reward_referrer | object | no | Reward paid to the referring user on claim. |
reward_referee | object | no | Reward paid to the claiming user. |
max_uses | number | no | Cap on claims; null = unlimited. |
reward_referrer and reward_referee are JSONB blobs; the redemption workflow interprets them (typically { xp: 100 } or { currency: "gems", amount: 50 }).
Response 201
Try it:
POST
developer auth/admin/projects/%7B%7BprojectId%7D%7D/referralscurl -X POST 'https://api.amba.dev/admin/projects/%7B%7BprojectId%7D%7D/referrals'Loading auth… Configure auth in the settings drawer (top-right) to run this request.
Curl:
GET /admin/projects/:projectId/referrals
Try it:
GET
developer auth/admin/projects/%7B%7BprojectId%7D%7D/referralscurl -X GET 'https://api.amba.dev/admin/projects/%7B%7BprojectId%7D%7D/referrals'Loading auth… Configure auth in the settings drawer (top-right) to run this request.
Curl:
GET /admin/projects/:projectId/referrals/:codeId/stats
Response 200
Errors
404 NOT_FOUND.
Try it:
GET
developer auth/admin/projects/%7B%7BprojectId%7D%7D/referrals/%7B%7BcodeId%7D%7D/statscurl -X GET 'https://api.amba.dev/admin/projects/%7B%7BprojectId%7D%7D/referrals/%7B%7BcodeId%7D%7D/stats'Loading auth… Configure auth in the settings drawer (top-right) to run this request.
Curl:
PATCH /admin/projects/:projectId/referrals/:codeId
Allowed fields: reward_referrer, reward_referee, max_uses, is_active.
Try it:
PATCH
developer auth/admin/projects/%7B%7BprojectId%7D%7D/referrals/%7B%7BcodeId%7D%7Dcurl -X PATCH 'https://api.amba.dev/admin/projects/%7B%7BprojectId%7D%7D/referrals/%7B%7BcodeId%7D%7D'Loading auth… Configure auth in the settings drawer (top-right) to run this request.
Curl:
DELETE /admin/projects/:projectId/referrals/:codeId
Try it:
DELETE
developer auth/admin/projects/%7B%7BprojectId%7D%7D/referrals/%7B%7BcodeId%7D%7Dcurl -X DELETE 'https://api.amba.dev/admin/projects/%7B%7BprojectId%7D%7D/referrals/%7B%7BcodeId%7D%7D'Loading auth… Configure auth in the settings drawer (top-right) to run this request.
Curl: