API Reference
Public methods, attribution adapters, and models exposed by the GrowSurf iOS SDK.
If you're using an AI tool such as Cursor, ChatGPT Codex, or Claude Code to help you implement GrowSurf, we recommend utilizing our MCP server.
Use this page to look up individual GrowSurf iOS SDK methods. All SDK methods use Swift concurrency unless otherwise noted.
Use the Mobile SDK public key in your app. Do not embed your secret REST API key in an iOS app.
SDK LIFECYCLE ↓
Configure
Call this once before using GrowSurf. It connects the SDK to your GrowSurf campaign and Mobile SDK public key.
let growsurf = GrowSurf.configure(
campaignId: "abc123",
publicKey: "pk_mobile"
)campaignId
String
(Required) Your GrowSurf program ID.
publicKey
String
(Required) Your Mobile SDK public key.
baseURL
URL
(Optional) Custom Mobile SDK API base URL. Defaults to https://api.growsurf.com/mobile/v2.
Returns a configured GrowSurf instance.
Example use
import GrowSurfSDK
let growsurf = GrowSurf.configure(
campaignId: "p9josq",
publicKey: "pk_mobile"
)Optionally, for advanced apps, initialize directly with explicit stores or a custom transport. Pass the production stores shown below, or your own conformances to the public store protocols:
Set participant token
Use this after your backend creates a mobile participant token for a signed-in user. It lets participant-scoped SDK calls load or update that participant's data.
token
String
(Required) A mobile participant token returned by your backend or by a participant creation method.
Returns Void.
Example use
Use this method with tokens created by the REST API mobile participant token endpoint after a user is already signed in.
Get participant token
Returns the participant token currently held by the SDK, or nil if none is stored. Useful right after the GrowSurf window's ParticipantFields signup flow so your app can persist the freshly minted token for the user's next session.
Returns String?.
Example use
Get current participant ID
Returns the current participant's ID decoded from the stored participant token, or nil if no participant token is set.
Returns String?.
Example use
Get mobile instance ID
Returns the app-install ID the SDK sends with participant creation for mobile anti-fraud. You usually only need this if your backend creates mobile participant tokens and needs to pass the same ID to GrowSurf.
Returns a lowercase UUID String.
Example use
Participant creation methods send mobileInstanceId automatically. Read it manually only when your backend creates a mobile participant token and needs to pass mobileInstanceId to the REST API.
Shutdown
Call this when a user signs out or you need to reset GrowSurf state on the device. It clears the stored session token, participant token, and pending attribution.
Returns Void.
Example use
CAMPAIGNS ↓
Get campaign
Use this to read campaign details and rewards for the configured GrowSurf program. The SDK creates or uses a session token before calling GrowSurf.
Returns GrowSurfCampaign.
Example use
Get leaderboard
Use this to show leaderboard rows in a custom referral screen. You can page through results with page or cursor parameters.
limit
Int?
(Optional) Number of rows to return.
page
Int?
(Optional) Page number.
offsetKey
String?
(Optional) Cursor key for offset-based pagination.
leaderboardType
String?
(Optional) Leaderboard type filter.
Returns GrowSurfLeaderboardResponse.
Example use
GROWSURF WINDOW ↓
Present GrowSurf window
Call this from your own button, menu item, or referral screen to open GrowSurf's native SwiftUI referral window.
The native GrowSurf window uses the GrowSurf window settings from your dashboard. This method is available on iOS.
from
UIViewController
(Required) The view controller that presents the native window.
identity
GrowSurfWindowIdentity
(Optional) How the window should identify the current user. Defaults to .anonymous.
theme
GrowSurfWindowTheme
(Optional) Native presentation and theme overrides.
callbacks
GrowSurfWindowCallbacks
(Optional) Event callbacks for window open, close, participant creation (from the signup form), share tracking, invite sending, payout/settings actions, and errors.
Returns GrowSurfWindowController — call close() on it to dismiss the window programmatically.
Example use
Get GrowSurf window
Use this when you are building your own referral screen instead of showing the native GrowSurf window. It returns the campaign, participant, share, reward, leaderboard, and affiliate data used by the window.
identity
GrowSurfWindowIdentity
(Optional) Window identity. Defaults to .anonymous.
Returns GrowSurfWindowResponse.
Example use
Use participant.shareUrl as the customer-facing referral link when a participant is available. Fall back to share.preferredUrl or share.fallbackUrl only for rendering.
ATTRIBUTION ↓
Handle deep link
Call this when your app opens from a referral deep link. If the URL contains grsf, ref, or referredBy, the SDK saves the attribution so you can apply it when the user signs up.
url
URL
(Required) The deep link URL opened by your app.
Returns GrowSurfAttribution?. Returns nil when no GrowSurf referral value is found.
Example use
Handle attribution parameters
Call this from an attribution provider callback, such as Branch, Adjust, AppsFlyer, or Singular. If the parameters include grsf, ref, or referredBy directly or inside URL-like values, the SDK saves the attribution for signup.
parameters
[String: String]
(Required) Provider callback parameters. The SDK recognizes direct values and nested URL-like values containing grsf, ref, or referredBy.
provider
String?
(Optional) Attribution provider name, such as branch, adjust, appsflyer, or singular.
Returns GrowSurfAttribution?. Returns nil when no GrowSurf referral value is found.
Example use
Get pending attribution
Use this to inspect referral attribution saved on this device before creating or signing in a participant.
Returns GrowSurfAttribution?.
Example use
Clear pending attribution
Clear saved referral attribution when it should no longer apply, such as after you handle it or when a different user signs in.
Returns Void.
Example use
Validate referrer
Use this to check whether a saved or supplied referrer is valid before you show a referred state or create a participant.
attribution
GrowSurfAttribution?
(Optional) Attribution to validate. If omitted, the SDK validates locally stored pending attribution.
Returns GrowSurfValidateReferrerResponse.
Example use
PARTICIPANTS ↓
Add referred participant
Use this for referred signups. The SDK looks for a saved or explicit referrer, validates it, and only creates the participant when the referral is valid.
input
GrowSurfParticipantInput
(Required) Participant fields, optional explicit referredBy, optional attribution, and optional metadata.
Returns GrowSurfAddReferredParticipantResponse.
Example use
If no participant is added, notAddedReason will be no_referrer, invalid_referrer, or participant_already_exists.
Add participant
Use this for public signup flows where the SDK can create a participant even without a referral. It sends pending attribution when available, stores the returned participant token when present, and includes the SDK-generated mobile instance ID for anti-fraud.
input
GrowSurfParticipantInput
(Required) Participant fields, optional attribution, and optional metadata.
Returns GrowSurfCreateParticipantResponse.
Example use
Use this method for public signup flows where the SDK should create a new participant. If the email already belongs to an existing participant, GrowSurf returns requiresParticipantToken: true and does not return a participant token. For signed-in or existing users, use an SDK-issued participant token you already have, or create a mobile participant token from your backend, then pass it to setParticipantToken(_:) or .existingParticipantToken(...).
Get participant
Use this after you have a participant token to load the participant's referral data, including their referral link and counts.
Returns GrowSurfParticipant.
Example use
Update participant
Use this when your app lets a participant update profile fields, such as first name, last name, or metadata.
with
GrowSurfParticipantUpdateInput
(Required) Fields to update, such as firstName, lastName, and metadata.
Returns GrowSurfParticipant.
Example use
Update vanity links
Use this when your app lets a participant manage multiple custom referral link keys at once.
vanityKeys
[String]
(Required) Vanity keys to associate with the participant.
Returns GrowSurfParticipant.
Example use
REFERRALS AND INVITES ↓
Get participant referrals
Use this to show who a participant has referred and the status of each referral.
limit
Int?
(Optional) Number of referrals to return.
offset
Int?
(Optional) Offset for pagination.
Returns GrowSurfReferralsResponse.
Example use
Send invites
Use this to send referral invite emails from a participant's referral screen.
emailAddresses
[String]
(Required) Email addresses to invite.
messageText
String
(Required) Invite message body.
subjectText
String?
(Optional) Invite email subject.
Returns GrowSurfInviteResponse.
Example use
Track share
Call this after a participant shares their referral link from your UI. GrowSurf records the share type, such as copy, email, sms, or a social channel.
type
String
(Required) Share type, such as copy, email, sms, or a social channel type returned by the GrowSurf window response.
Returns GrowSurfSuccessResponse.
Example use
REFERRAL PROGRAMS ↓
Trigger referral
Referral programs only
Use this when a referred participant completes the in-app action that should count as a referral conversion. For purchases or other high-trust events, trigger referral credit from your backend instead.
Returns GrowSurfSuccessResponse.
Example use
For server-verified purchases, subscriptions, or other high-trust reward events, trigger referral credit from your backend using the REST API or a GrowSurf integration instead of from the app.
Get participant rewards
Referral programs only
Use this to show the rewards a participant has earned or can track inside your app.
limit
Int?
(Optional) Number of rewards to return.
nextId
String?
(Optional) Cursor ID for the next page.
Returns GrowSurfRewardsResponse.
Example use
Mark participant rewards read
Referral programs only
Call this after showing reward notifications so GrowSurf can clear the participant's unread reward state.
Returns GrowSurfSuccessResponse.
Example use
Get participant referral summary
Referral programs only
Use this for referral programs to show a participant's high-level referral stats (referrals, leads, expired referrals, clicks, rewards earned, pending rewards, invites sent).
Returns GrowSurfReferralSummary.
Example use
AFFILIATE PROGRAMS ↓
Get participant commissions
Affiliate programs only
Use this for affiliate programs to show a participant's commission history.
limit
Int?
(Optional) Number of commissions to return.
nextId
String?
(Optional) Cursor ID for the next page.
Returns GrowSurfCommissionsResponse.
Example use
Mark participant commissions read
Affiliate programs only
Call this after showing commission notifications so GrowSurf can clear the participant's unread commission state.
Returns GrowSurfSuccessResponse.
Example use
Get participant payouts
Affiliate programs only
Use this for affiliate programs to show a participant's payout history.
limit
Int?
(Optional) Number of payouts to return.
nextId
String?
(Optional) Cursor ID for the next page.
Returns GrowSurfPayoutsResponse.
Example use
Mark participant payouts read
Affiliate programs only
Call this after showing payout notifications so GrowSurf can clear the participant's unread payout state.
Returns GrowSurfSuccessResponse.
Example use
Get participant affiliate summary
Affiliate programs only
Use this for affiliate programs to show a participant's high-level affiliate stats, such as referral revenue, total paid out, and upcoming payout.
Returns GrowSurfAffiliateSummary.
Example use
Request PayPal confirm email
Affiliate programs only
Use this when your affiliate program needs the participant to confirm their PayPal email before payouts can continue.
Returns GrowSurfSuccessResponse.
Example use
Request tax info session
Use this when the campaign requires tax documentation and the participant needs to complete or resubmit their W-9 / W-8 form before rewards or payouts can continue. It starts a secure hosted tax-form session and returns the hosted URL to open in an in-app browser, plus the participant's new tax status. The native GrowSurf window calls this automatically from its Tax Forms settings row; call it yourself only if you build a custom settings UI.
Returns GrowSurfTaxSessionResponse.
Example use
GrowSurf never stores participant tax IDs. The W-9 / W-8 is completed on a hosted page served by GrowSurf's IRS-authorized e-file partner.
ATTRIBUTION ADAPTERS ↓
Branch attribution adapter
Use this helper when Branch returns attribution data. It normalizes Branch payloads and can store the resulting GrowSurf attribution on the SDK.
normalize(_ parameters: [String: String])
Parses a string dictionary and returns GrowSurfAttribution? without storing it.
normalize(_ parameters: [String: Any])
Converts a mixed dictionary, then parses attribution without storing it.
normalize(_ parameters: [AnyHashable: Any])
Converts a hashable-key dictionary, then parses attribution without storing it.
handle(_ parameters: [String: String], sdk:)
Parses and stores attribution on the provided SDK instance.
handle(_ parameters: [String: Any], sdk:)
Converts, parses, and stores attribution on the provided SDK instance.
handle(_ parameters: [AnyHashable: Any], sdk:)
Converts, parses, and stores attribution on the provided SDK instance.
Example use
Adjust attribution adapter
Use this helper when Adjust returns a deep link. It normalizes the URL and can store the resulting GrowSurf attribution on the SDK.
normalize(_ url: URL)
Parses a URL and returns GrowSurfAttribution? without storing it.
normalize(_ urlString: String)
Parses a URL string or encoded URL string without storing it.
handle(_ url: URL, sdk:)
Parses and stores attribution on the provided SDK instance.
handle(_ urlString: String, sdk:)
Parses and stores attribution on the provided SDK instance.
Example use
AppsFlyer attribution adapter
Use this helper when AppsFlyer returns conversion or deep link data. It normalizes the payload and can store the resulting GrowSurf attribution on the SDK.
normalize(_ parameters: [String: String])
Parses a string dictionary and returns GrowSurfAttribution? without storing it.
normalize(_ parameters: [String: Any])
Converts a mixed dictionary, then parses attribution without storing it.
normalize(_ parameters: [AnyHashable: Any])
Converts a hashable-key dictionary, then parses attribution without storing it.
handle(_ parameters: [String: String], sdk:)
Parses and stores attribution on the provided SDK instance.
handle(_ parameters: [String: Any], sdk:)
Converts, parses, and stores attribution on the provided SDK instance.
handle(_ parameters: [AnyHashable: Any], sdk:)
Converts, parses, and stores attribution on the provided SDK instance.
Example use
Singular attribution adapter
Use this helper when Singular returns callback parameters or deep link values. It normalizes the payload and can store the resulting GrowSurf attribution on the SDK.
normalize(_ parameters: [String: String])
Parses a string dictionary and returns GrowSurfAttribution? without storing it.
normalize(_ parameters: [String: Any])
Converts a mixed dictionary, then parses attribution without storing it.
normalize(_ parameters: [AnyHashable: Any])
Converts a hashable-key dictionary, then parses attribution without storing it.
normalize(_ url: URL)
Parses a URL without storing it.
normalize(_ urlString: String)
Parses a URL string or encoded URL string without storing it.
handle(_ parameters: [String: String], sdk:)
Parses and stores attribution on the provided SDK instance.
handle(_ parameters: [String: Any], sdk:)
Converts, parses, and stores attribution on the provided SDK instance.
handle(_ parameters: [AnyHashable: Any], sdk:)
Converts, parses, and stores attribution on the provided SDK instance.
handle(_ url: URL, sdk:)
Parses and stores attribution on the provided SDK instance.
handle(_ urlString: String, sdk:)
Parses and stores attribution on the provided SDK instance.
Example use
UTILITIES ↓
Normalize attribution parameters
Use this when you need to read GrowSurf attribution from raw provider parameters without storing it. It looks for grsf, ref, or referredBy directly and inside URL-like values.
parameters
[String: String]
(Required) Raw parameters. The normalizer checks direct fields and URL-like nested values.
provider
String?
(Optional) Provider name to attach to the attribution result.
Returns GrowSurfAttribution?.
Example use
Normalize attribution URL
Use this when you need to parse a URL for grsf, ref, or referredBy without storing attribution on the SDK.
url
URL
(Required) URL to parse.
provider
String?
(Optional) Provider name to attach to the attribution result.
Returns GrowSurfAttribution?.
Example use
Convert attribution parameters to strings
Use this before passing mixed provider callback payloads to the normalizer or SDK attribution methods. It converts nested values into a [String: String] dictionary without storing attribution.
parameters
[String: Any]
(Required) Provider callback payload. Nested dictionaries and arrays are flattened into string values.
Returns [String: String].
Example use
Last updated
Was this helpful?