Profile Sync
Pre-populate user data during authentication
Pre-populate user data during authentication
When a user authenticates, the SDK can send partner-collected data — profile details, address, insurance, and dependents — alongside the auth.upgrade message. Sunny uses this to pre-populate the user’s account, removing the need for the user to re-enter information they’ve already provided to your application.
Profile sync data is included in the auth.upgrade WebSocket message that fires when a user authenticates. The backend uses upsert semantics: it only creates or updates records for the fields you provide, and leaves everything else untouched.
Pass authUpgradeProfileSync to createSunnyChat. You can provide static data or an async function that resolves the data at authentication time.
Use a function when the data needs to be fetched at authentication time — for example, from your own API:
Returning null from the provider skips profile sync entirely — the user authenticates normally without any pre-populated data.
All fields in authUpgradeProfileSync are optional. Include only what your application has collected.
Basic demographic information. All fields are optional; only provided fields are updated.
Mailing address for the user. When provided, address_line_1, city, state, and zip_code are required.
Insurance plan records. Reference the plan with exactly one of partner_plan_id (the plan’s UUID from Sunny Central) or plan_alias (a developer-defined alias configured for your partner). Aliases let you use a stable, human-readable identifier instead of managing raw UUIDs, and are resolved at runtime, scoped to your partner. Either way, this requires partnerIdentifier on the SDK connection.
Referencing a plan by alias:
Add and manage aliases from the Developer Tools → Plans & Aliases section of the Sunny Central dashboard. Plans themselves are configured by Sunny — contact your integration owner to add or change a plan.
Family members or dependents covered under the user’s insurance. Each dependent can be linked to a specific insurance plan by index.
The relationship_code field uses Stedi relationship codes:
The insurance_index field links a dependent to a specific entry in the insurances array (zero-based). If omitted, the dependent is associated with the first insurance plan.
A complete example syncing all data types with an async provider:
auth.upgrade message is sent. This ensures data is as fresh as possible.