Overview
The Create Referral endpoint allows you to register a new referral signup in your system. This is a critical endpoint that links:- The impression (QR scan) that initiated the referral
- The person who signed up (referral)
- The student ambassador who generated the referral
- The program the referral belongs to
- Register new signups from referral links
- Track the conversion funnel from QR scan to signup
- Associate referrals with their originating impressions
- Enable commission tracking for ambassadors
Authentication
This endpoint requires authentication using a Bearer token in the Authorization header:Request Body
Required. The ID of the impression (QR scan) that led to this referral. This links the referral back to the original QR code scan and poster placement.Example:
imp_123abcNote: The impression must exist in your system before creating a referral.Required. First name of the person who signed up via the referral link.Example:
JohnRequired. Last name of the person who signed up via the referral link.Example:
DoeRequired. Email address of the referred person. This should be a valid email address and is used for communication and verification.Example:
john.doe@example.comOptional URL to the profile picture of the referred person. This can be used to display avatars in dashboards.Example:
https://example.com/profiles/john-doe.jpgOptional additional metadata about the referral. Use this to store custom information like signup source, marketing campaign, or other relevant data.Example:
Optional unique key for idempotent requests. If you send the same
idempotency_key within a short time window, the API will return the same referral instead of creating a duplicate. This is useful for retry logic.Example: idemp_20240115_123456Best Practice: Use a combination of timestamp and unique identifier to ensure uniqueness.Request Example
Response
On success, the API returns the created referral object:Unique identifier for the newly created referral.
The impression ID that was provided in the request.
First name of the referral.
Last name of the referral.
Email address of the referral.
Initial status of the referral, typically
pending.ID of the program, automatically determined from the impression.
ID of the student ambassador, automatically determined from the impression.
ISO 8601 timestamp of when the referral was created.
Response Example
Error Responses
Bad Request - Invalid request dataCommon causes:
- Missing required fields
- Invalid email format
- Invalid impression_id (impression doesn’t exist)
Unauthorized - Invalid or missing API key
Use Cases
Handling Signup Webhooks
When a user signs up via a referral link, create the referral:Idempotent Referral Creation
Use idempotency keys to prevent duplicate referrals:Batch Referral Creation
Create multiple referrals in sequence:Best Practices
- Always use idempotency keys - Prevents duplicate referrals if your request is retried
- Validate impression_id - Ensure the impression exists before creating the referral
- Store metadata - Use the metadata field to track useful information for analytics
- Handle errors gracefully - Check for 400 errors and provide user-friendly messages
- Verify email format - Validate email addresses before sending to the API
- Link to impressions - Always provide a valid
impression_idto maintain the referral chain
Workflow
The typical referral creation workflow:- User scans QR code → Impression created
- User clicks through and signs up → Referral created (this endpoint)
- User makes a purchase → Earning created (see Earnings API)
- Referral status updated to
converted
Rate Limits
This endpoint is subject to rate limiting. Check response headers for rate limit information.Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
The impression (QR scan) ID that led to this referral
URL to profile picture
Additional metadata about the referral
A unique key for idempotent requests
Response
Referral created successfully