1. Referral
Returning.AI
  • Getting Started
  • Users
    • Get user
      GET
    • Get Users with Filters
      POST
    • Create New User
      POST
    • Get User Data
      POST
    • Manage User Account
      POST
    • List mini-game logs by user email
      POST
    • Get current mini-game and streak state
      POST
    • Get User Milestones
      POST
    • Update User Data, Identifier, And Roles
      POST
    • Update User XP and Currency
      POST
  • Messaging
    • Agent messaging workflow
    • Get Messages
      GET
    • Send Message
      POST
    • Reply Message
      POST
    • React Message
      POST
    • Upload message images
      POST
  • Gamification
    • Leaderboards
      • List leaderboards with pagination
      • Create a new leaderboard
      • Update an existing leaderboard
      • Get a single leaderboard by ID
      • Delete a leaderboard
    • Streaks & Mini Games
      • List user streak logs
      • Update user spin-wheel information
    • Referral
      • Referral Program Integration
      • Mini-game State and History
      • Get referral programs
        GET
      • Get user's referral summary
        POST
    • Rolling Data
      • Get Daily Calculation Data
      • Get Rolling Calculation Data
    • Match Predictions
    • Get tier configuration
      GET
    • Get daily user XP and coin changes
      POST
    • Search user gamification logs
      POST
    • Get user activity stats
      POST
  • Rewards & Redemptions
    • Update redemption order status or refund
    • List redemption orders by user email
    • List redemption statuses
    • Get redemption status by ID
    • List redemption orders by community
    • Create redemption order status
    • Get redemption order status history
  • Chart Analysis
    • Create Analysis
    • Get Analysis
    • Update Analysis
    • Delete Analysis
    • List Analyses
    • Append Drawings
  • Bulk Operations
    • List bulk update jobs
    • Get bulk update job status
    • Get bulk update job details
    • Bulk update users from CSV
    • Bulk update premium currency from CSV
  • Channels
    • Iframe
    • List integration channels
  • Events
    • Outgoing webhooks
      • Encryption
      • User Joins Server
      • User Visits server
      • New Message Posted Anywhere
      • New Message Posted To channel
      • Purchased Store Item
    • Incoming webhooks
      • API Keys & Encryption
      • Send message into channels
      • Update Custom User Fields
      • Update In-game currency
  • Widgets
    • Authenticated Widgets
    • Public widgets
  • Community Analytics
    • Get Loyalty Overview
    • Get Phone Verification Contacts
  • Store
    • Purchase History
      • Update redemption instructions or voucher details
    • Categories
      • List Store categories
      • Create Store category
      • Get Store category by ID
      • Update Store category
      • Delete Store category
    • Products
      • List products
      • Update products in bulk
      • Create products in bulk
      • Create product with vouchers
      • Read product
      • Update product and append vouchers
      • Delete product
    • Redemption-transaction
      • Get redemption transaction detail
    • Get Store configuration
    • Update Store configuration
  • Community
    • Appearance
      • Update community theme colors
      • Update community bot profile
      • Update community URL metadata
      • Update community name and URL
    • Community Users
      • Get community users
      • Get user
    • Create community
  • API Keys
    • Community API Keys
      • Create API key
      • Read API keys
      • Delete API key
      • Update API key
    • User API Keys
      • List user API keys
      • Create user API key
      • Update user API key
      • Delete user API key
      • Get current API key information
  • User Fields
    • User Field History
      • Get all user field histories in a community
      • Get user field histories for a specific field
      • Get user field histories for a specific user
      • Get user field histories of specific user field and user
      • Update A User Field Value
      • Deprecated Field-First History Write
      • Deprecated Field-First History Read
    • Get A User Field Definition
    • Update A User Field Definition
    • Create A User Field Definition
    • Delete A User Field Definition
    • List User Field Definitions
    • Delete user field
    • Update user field
    • Get specific user field
  • Legacy
    • Servers
      • Create server
      • List servers
      • Update server metadata
    • Bulk Operations
      • Bulk import users from CSV
    • Authentication
      • Secure Auth
      • Register user with password
      • Verify user email
      • Log in user with password
    • Badges
      • List badges
      • Create badge
      • Update badge
      • Delete badge
      • Remove badge from user
      • Award badge to user
    • Messaging
    • Roles & Permissions
      • List server roles
      • Create role
      • Update role
      • Delete role
      • List user roles
      • Add role to user
      • Remove role from user
    • Users
      • Upload user avatar
    • Channels
      • Create channel
      • Update channel
      • Delete channel
    • API Keys
      • List integration API keys
      • Create integration API key
      • Delete integration API key
      • Update integration API key
  • Schemas
    • Sample Schemas
    • Schemas
    • Outgoing webhooks
    • Analysis
    • Pet
    • Category
    • Tag
    • ValidationError
    • NotFoundError
    • InternalServerError
    • NotImplementedError
    • CreateUserFieldHistoryResponse
    • CreateUserFieldHistorySuccessResponse
    • UserFieldHistoryItem
    • GetUserFieldHistoriesResponse
    • UserFieldHistoriesValidationError
    • UserFieldHistoriesMetaWithValidation
    • UserFieldHistoriesMetaWithPagination
    • GetUserFieldHistoriesSuccessResponse
    • CreateUserFieldResponse
    • CreateUserFieldSuccessResponse
    • DeleteUserFieldResponse
    • DeleteUserFieldSuccessResponse
    • UserFieldCreator
    • GetUserFieldResponse
    • GetUserFieldSuccessResponse
    • ValidationErrorItem
    • GetUserFieldsMetaResponse
    • CreatorInfo
    • UserFieldResponse
    • GetUserFieldsSuccessResponse
    • UpdateUserFieldResponse
    • UpdateUserFieldPayload
    • UpdateUserFieldSuccessResponse
    • MetaResponse
    • GetUserResponse
    • GetUserSuccessResponse
    • Purchased store item
    • ErrorResponse
    • New message posted to channel
    • UpdateAnalysisRequest
    • User visits server
    • AppendDrawingsRequest
    • User join server
    • CreateAnalysisResponse
    • GetAnalysisResponse
    • UpdateAnalysisResponse
    • AppendDrawingsResponse
    • AnalysisMetadata
    • Expiry
    • Levels
    • LevelEntry
    • Drawing
    • HorizontalLineDrawing
    • LineDrawing
    • RectangleDrawing
    • ParallelDrawing
    • FibonacciRetracementDrawing
    • Coordinate
    • DrawingStyle
    • AnalysisDetail
    • AnalysisSummary
    • CreateAnalysisRequest
    • ListAnalysesResponse
    • StandardApiError
    • StandardSuccessEnvelope
    • PurchasedStoreItemEvent
    • ChannelMessagePostedEvent
    • UserVisitedCommunityEvent
    • UserJoinedCommunityEvent
  1. Referral

Referral Program Integration

Use this guide to connect a broker, membership platform, or customer portal to a Returning.AI referral program without coupling the integration to one community's field names, milestones, reward amounts, or page design.
WARNING
Keep community API keys server-side. Do not put them in browser code, mobile bundles, query strings, logs, screenshots, or analytics events.

What Returning.AI configures and what your integration sends#

Returning.AI administrators configure programs, stages, condition groups, rewards, and the invite-link template. Your integration supplies durable member identity, captures the referral value, registers the new member, sends the configured business signals, and reads the resulting summary.
Program names, stage counts, condition keys, invite parameters, and rewards are community configuration. Discover them rather than copying values from an example.

1. Confirm the active program#

Call Get referral programs with the target community's API key.
Check that:
at least one expected program is enabled;
stages appear in the intended display order;
each user-facing condition describes the intended milestone;
stage and total rewards match the approved configuration;
the response is from the same community and environment used for registration.
A successful response with data: [] means the API call worked but no public referral program is active.

2. Choose one stable member identity#

Pick a broker-owned identifier that does not change when a member updates their name or email. Examples include a customer number, account UUID, or identity-provider subject. Confirm how that value maps to Returning.AI before launch.
Use the same identity consistently in four places:
1.
the member's Returning.AI registration;
2.
the invite-link dynamic value;
3.
the new referee's top-level referral value;
4.
later summary and widget lookups.
Email can be used when it is the configured mapping, but a mutable email is usually a weaker long-term key than an immutable customer identifier.
INFO
The new user's own stable identifier and the referrer's stable identifier are different values. Store the new user's own identifier on the new user. Send the referrer's identifier only in the referral relationship field.

3. Configure the invite URL#

The referral program can expose a client-facing invite.url and a Returning.AI fallback platformUrl.
A client-facing template usually contains one dynamic value, for example:
https://portal.example.com/join?ref={{stable_member_id}}
When member broker-customer-10482 requests their summary, the rendered URL might be:
https://portal.example.com/join?ref=broker-customer-10482
Treat the query parameter name and URL origin as configuration. Do not assume every community uses ref, and do not reconstruct the URL when invite.url is already returned.

4. Capture the referral before registration#

When a visitor arrives through an invite link, capture the referral value before registration starts. Preserve it through redirects, email verification, identity-provider callbacks, and multi-step onboarding. Validate the value as data; never execute or interpolate it into code.
At registration time:
send the new user's own stable identifier in the configured member field;
if the visitor was referred, send the referrer's stable identifier in the top-level referral field;
do not copy the referrer's identifier into the new user's own identity field;
omit the referral field entirely for an organic, non-referred member.
Conceptual payload fragment:
{
  "email": "new-member@example.com",
  "customFields": [
    {
      "fieldIdorName": "brokerAccountId",
      "value": "broker-customer-20491"
    }
  ],
  "referral": "broker-customer-10482"
}
Create the member with Create New User, then read the saved identity with Get User Data. Field names are illustrative; use the mapping configured for your community.

5. Send milestone signals through the member lifecycle#

Referral stages evaluate configured conditions. A stage might represent registration, account approval, first deposit, first purchase, or another community-specific milestone.
Do not invent a separate referral-trigger write. Send the real business state through the normal user creation, user update, custom-field, event, or workflow path agreed for the community. The referral service evaluates that state against the current program.
For later member changes, use the documented Update User Data or the approved workflow for the configured condition field. Verify the saved user state before expecting a referral stage to complete.
WARNING
A boolean or status field belongs to the referred member whose action occurred. Do not set a milestone true merely to force a reward, and do not send a referrer's status as the referee's status.

6. Read the current member's referral summary#

Call Get user's referral summary with the same identity namespace used at registration.
{
  "identifier": {
    "type": "data-customer-id",
    "value": "broker-customer-10482"
  },
  "pagination": {
    "limit": 20
  }
}
Use custom-field only when the identity is stored in a named custom field, and then include the exact fieldName. A valid member with no referrals returns 200, zero counters, and an empty referees array.

7. Handle eventual consistency and pagination#

User creation, referral association, condition evaluation, and reward aggregation can complete asynchronously. After a write:
1.
read the member back by the same stable identity;
2.
poll the referral summary with bounded backoff;
3.
stop when the expected referee or stage appears, or when the test timeout is reached;
4.
record the last response and correlation context before escalating.
When pagination.hasNextPage is true, pass the returned opaque nextCursor as the next request's pagination.cursor. Do not decode it, change it, or reuse it with a different member, program filter, or community key.

Retry and idempotency rules#

Programs and summary reads are idempotent. They are safe to retry with bounded backoff.
Do not blindly retry user creation. A timeout may hide a successful create and a second submission can conflict or duplicate downstream work. Read by the stable identifier first.
Do not replay milestone writes merely because summary propagation is delayed. Read the saved user state and poll summary before resubmitting.
Keep a caller-owned correlation ID in logs, but do not claim it is an API idempotency key unless the specific write endpoint documents that behavior.

End-to-end acceptance matrix#

Use disposable synthetic members in staging.
CaseSetupExpected summary
Referrer onlyCreate a member with no referral200, invite URL present, zero activity, no referees
Joined refereeCreate a second member with the referrer's stable IDReferee appears; registration stage completes when configured
Qualified refereeSend the configured milestone on the referred memberLater stage and corresponding reward complete
Negative controlCreate an otherwise similar member without a referralMember does not appear in the referrer's summary
Unknown memberQuery a synthetic identifier that was never registered404 User not found
PaginationCreate enough referred members to exceed a small limithasNextPage and nextCursor advance without duplicates
Do not run reward-bearing production acceptance tests without an approved test user, reward boundary, and cleanup decision.

Launch checklist#

Production and staging API keys are stored separately and include getUserData.
The stable identity mapping is written down and tested with two distinct members.
The invite-link parameter survives the complete registration journey.
The new user's own identity and the referrer's identity are not swapped.
Program stages and rewards match the approved configuration.
Milestone signals update the referred member through the approved path.
Zero-activity, joined, qualified, negative-control, unknown-user, and pagination cases pass in staging.
Summary polling has a bounded timeout and does not trigger blind write retries.
Browser code never receives the community API key.
Production monitoring distinguishes authentication, identity-resolution, propagation, and configuration failures.

Troubleshooting#

401 API key is required or Invalid API key#

Confirm the Authorization: Bearer <COMMUNITY_API_KEY> header, environment, expiration, and secret injection. Do not paste the key into a ticket or browser console.

403 permission error#

The key is valid but lacks getUserData. Update the key's permissions or use the intended integration key.

404 User not found#

Check that the member exists in the API key's community and that identifier.type, value, and optional fieldName match registration exactly. Do not switch identifier types until the mapping is confirmed.

Invite URL contains the wrong member value#

Verify that the invite template uses the referrer's own stable identity field and that the field was populated before summary rendering.

Referee does not appear#

Verify capture-before-registration ordering, read the new member back, confirm the top-level referral value is the referrer's identity, and allow bounded time for asynchronous association.

Stage remains in progress#

Read the referred member's saved business state, compare it with the current program conditions, and confirm the signal was written to the referred member in the expected type and environment.

Negative-control member is counted#

Stop launch. The organic member should have no referral relationship. Capture the sanitized create request shape and summary evidence, then escalate the attribution defect.

API references#

Get referral programs
Get user's referral summary
Create New User
Get User Data
Update User Data
Modified at 2026-08-17 15:23:55
Previous
Update user spin-wheel information
Next
Mini-game State and History
Built with