Onboarding API
The onboarding router tracks per-tenant onboarding state, including business model selection, step completion, and banner dismissal. The onboarding checklist is non-linear -- steps can be completed in any order.
Router namespace: onboarding
Source: src/server/trpc/routers/onboarding.ts
Procedures
| Procedure | Type | Access | Description |
|---|---|---|---|
getProgress | query | tenant | Get full onboarding state |
updateStep | mutation | tenant | Mark a step complete or incomplete |
setBusinessModel | mutation | tenant | Set the tenant's business model |
dismissBanner | mutation | tenant | Hide the onboarding banner |
getProgress
Returns the complete onboarding state for the current tenant, including business model, step completion status, and whether the banner has been dismissed.
onboarding.getProgress.queryOptions()
Input
None.
Response
{
"businessModel": "b2b",
"steps": {
"connectCrm": true,
"mapFields": true,
"configureScoring": false,
"runFirstSync": false
},
"dismissedBanner": false,
"completedAt": null
}
When all four steps are complete, completedAt is set to the ISO 8601 timestamp of the final step completion.
Example
const trpc = useTRPC();
const { data: progress } = useQuery(
trpc.onboarding.getProgress.queryOptions()
);
const allComplete = progress && Object.values(progress.steps).every(Boolean);
updateStep
Marks an onboarding step as complete or incomplete. Steps can be toggled in any order.
onboarding.updateStep.mutationOptions(options)
Input
| Field | Type | Required | Description |
|---|---|---|---|
step | "connectCrm" | "mapFields" | "configureScoring" | "runFirstSync" | Yes | Step identifier |
completed | boolean | Yes | Whether the step is complete |
Response
{
"success": true
}
Example
const trpc = useTRPC();
const queryClient = useQueryClient();
const mutation = useMutation(
trpc.onboarding.updateStep.mutationOptions({
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: trpc.onboarding.getProgress.queryKey(),
});
},
})
);
mutation.mutate({ step: "connectCrm", completed: true });
setBusinessModel
Sets the tenant's business model, which controls label terminology throughout the dashboard (e.g., "Accounts" vs "Customers" for B2B vs B2C).
onboarding.setBusinessModel.mutationOptions(options)
Input
| Field | Type | Required | Description |
|---|---|---|---|
businessModel | "b2b" | "b2c" | Yes | Business model selection |
Response
{
"success": true
}
Example
const trpc = useTRPC();
const mutation = useMutation(
trpc.onboarding.setBusinessModel.mutationOptions({})
);
mutation.mutate({ businessModel: "b2b" });
Setting the business model updates the TenantLabelsProvider context. Components using useLabels() will automatically reflect the new terminology.
dismissBanner
Hides the onboarding banner from the dashboard. The banner can still be accessed from settings. This is a one-way toggle -- there is no procedure to un-dismiss.
onboarding.dismissBanner.mutationOptions(options)
Input
None.
Response
{
"success": true
}
Example
const trpc = useTRPC();
const queryClient = useQueryClient();
const mutation = useMutation(
trpc.onboarding.dismissBanner.mutationOptions({
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: trpc.onboarding.getProgress.queryKey(),
});
},
})
);
mutation.mutate();
Related Pages
- Tenant API -- Tenant settings and configuration
- Connector API -- CRM connection (step 1)
- Field Mappings API -- Field mapping (step 2)
- Scoring Config API -- Scoring configuration (step 3)