Get referral programs
List the referral programs set up in the community that owns your API key, with each stage's requirements and rewards.
- Method
- GET
- Path
https://api.returning.ai / v1/ referral/ programs - Permission
- getUserData
- Retries
- Read-only; exact retries are safe
When to use this
- Show traders which referral programs exist, what each stage asks of the people they invite, and what it pays.
- Check a program's stages and rewards before you launch it.
- Find a
programIdto filter Get user's referral summary by.
Authentication#
- Header
Authorization: Bearer <API_KEY>- Permission
- getUserDataShown in the dashboard as “Get User Data”
Send a Community API key with getUserData, shown in the dashboard as Get User Data. The key decides the community, so never send a community ID. Keep the key on your server.
Behaviour#
This read changes nothing and returns your programs as they are set up now, not any trader's progress. It includes programs that are switched off, so check enabled before you show one to traders. Programs with no stages and deleted programs are left out.
Condition keys, values and rewards differ between communities and change when an admin edits a program. Render what the response returns rather than hard-coding stage counts, names or amounts.
With a lang other than en, names, descriptions and requirement text come back translated. A translation that doesn't exist yet is made on the first request, which can make that request slower.
Request#
Query parameters#
fr. Omit it, or send en, for the text as it was entered.RuleLanguage code
Egen
Headers#
getUserData.RuleBearer <API_KEY>
curl --request GET \
--url 'https://api.returning.ai/v1/referral/programs?lang=en' \
--header 'Authorization: Bearer <API_KEY>'
Response#
A 200 returns the programs in data. An empty data means your community has no referral programs with stages. Branch on the HTTP status.
Eg{"status": "success", "statusCode": 200}
Rulesuccess
Eg200
Eg"Get referral programs success."
Eg[ ... ]
programId to Get user's referral summary.Eg"66f000000000000000000710"
Eg"Invite a trader"
Eg"Earn rewards as the traders you invite get started."
true when the program is running. Switched-off programs are listed too, with false.Egtrue
Eg"#4F46E5"
xp and coins. It is paid on top of the stage rewards, not their sum. 0 when there is no bonus.Eg{"xp": 0, "coins": 100}
Eg0
Eg100
Eg[ ... ]
Eg"66f000000000000000000711"
Eg1
Eg"Get active"
Eg"Your friend earns more than 500 XP."
Rulecondition, description or condition_and_description
Eg"condition"
xp and coins. 0 when that reward is off.Eg{"xp": 250, "coins": 25}
Eg250
Eg25
and when every condition group must be met, or when one is enough.Ruleand or or
Eg"and"
Eg[ ... ]
Eg"66f000000000000000000712"
and when every condition in the group must be met, or when one is enough.Ruleand or or
Eg"and"
true when the group's own text is shown to traders.Egfalse
Eg[ ... ]
Eg"66f000000000000000000713"
total_xp, messages_sent, role or one of your user fields.Eg"total_xp"
number, date, role or tag.Eg"number"
is, is_not, more_than, less_than, before or after.Eg"more_than"
type.Eg500
value in readable form, such as a role or tier name, or a formatted date.Eg"500"
true when value points to a role, tag, trader, tier or badge that no longer exists. valueLabel then reads Deleted Role, Deleted Tag and so on.Egfalse
true when the condition's own text is shown to traders.Egtrue
Eg"Earn more than 500 XP"
{
"meta": {
"status": "success",
"statusCode": 200
},
"message": "Get referral programs success.",
"data": [
{
"enabled": true,
"programId": "66f000000000000000000710",
"name": "Invite a trader",
"description": "Earn rewards as the traders you invite get started.",
"color": "#4F46E5",
"icon": "",
"totalRewards": {
"xp": 0,
"coins": 100
},
"stages": [
{
"stageId": "66f000000000000000000711",
"stageNumber": 1,
"name": "Get active",
"description": "Your friend earns more than 500 XP.",
"displaySetting": "condition",
"mainConditionOperator": "and",
"mainConditions": [
{
"groupId": "66f000000000000000000712",
"operator": "and",
"enableUserFacingCondition": false,
"nestedConditions": [
{
"conditionId": "66f000000000000000000713",
"key": "total_xp",
"type": "number",
"condition": "more_than",
"value": 500,
"enableUserFacingCondition": true,
"userFacingCondition": "Earn more than 500 XP",
"valueLabel": "500",
"isDeletedValue": false
}
]
}
],
"rewards": {
"xp": 250,
"coins": 25
}
}
]
}
]
}
Errors#
401, 403 and 502 errors carry a code in meta.code. A 500 carries INTERNAL_ERROR, or no code at all with message Get referral programs error.; treat both the same. Branch on the HTTP status.
Fix the request03
AUTH_API_KEY_REQUIREDFix the requestAuthorization: Bearer <API_KEY>.AUTH_API_KEY_INVALIDFix the requestAUTH_PERMISSION_REQUIREDFix the requestgetUserData. Add Get User Data in Settings > Integration > API Keys.Retry with backoff03
STORE_DEPENDENCY_UNAVAILABLERetry with backoffINTERNAL_ERRORRetry with backoffAUTH_API_KEY_VALIDATION_FAILEDRetry with backoff{
"meta": {
"status": "error",
"statusCode": 401,
"code": "AUTH_API_KEY_REQUIRED"
},
"message": "API key is required",
"detail": "No Bearer token found in Authorization header",
"solution": "Please provide a valid API key in the Authorization header as Bearer <key>"
}