Account switcher & multi-account analytics — frontend integration
This guide describes the creator (Sanctum) API for multi-account login, backend-owned master/child account groups, and aggregated dashboard metrics. Client storage, UI, and routing are owned by the frontend team.
Environments
| Environment | API base | Swagger UI |
|---|---|---|
| Development | https://fangate.co/api | https://fangate.co/api/documentation |
| Production | https://fangate.info/api | https://fangate.info/api/documentation |
Static developer docs: https://docs.fangate.app
Goals
- Master account — the first account that links others; sees all linked children after login (
account_group.role === "master"). - Child account — linked under a master; login returns only self plus
account_group.mastermetadata — no sibling list, no group management. - Relationships are stored in
account_group_memberson the backend (survive logout, browser reset, device changes). - Switching — master may call
POST /api/user/linked-accounts/{childUserId}/sessionto obtain a child token, or use their own token for master-scoped aggregate APIs. - Combined KPIs —
POST /api/dashboard/summary/aggregatemerges metrics for masters using persisted links only (not client-supplied tokens).
Account group (account_group)
Returned on POST /api/login, POST /api/register, GET /api/user, and each POST /api/login/batch session row.
json
{
"role": "master",
"master": null,
"linked_accounts": [
{
"id": 12,
"child_user_id": 42,
"email": "child@example.com",
"display_name": "Child Creator",
"currency_id": 1,
"currency_code": "EUR",
"linked_at": "2026-05-18T12:00:00+00:00"
}
]
}role | linked_accounts | master | Client behaviour |
|---|---|---|---|
standalone | [] | null | Single-account UX; may link children via API. |
master | Non-empty list of children (metadata only, no tokens) | null | Show account switcher for all linked children; use session endpoint or aggregate. |
child | [] (always) | Master summary object | Show one account only; hide sibling/master group UI. |
Do not treat locally stored tokens as proof of access to other creators — use account_group from the latest login / GET /api/user.
Endpoints
| Method | Path | Auth | Description |
|---|---|---|---|
POST | /api/login | No | Returns user, token, account_group. |
POST | /api/register | No | Same account_group shape (usually standalone). |
GET | /api/user | Bearer | Returns user + account_group. |
POST | /api/login/batch | No | Up to 10 accounts; each session includes account_group. |
GET | /api/user/linked-accounts | Bearer | Refresh account_group for the current user. |
POST | /api/user/linked-accounts | Bearer | Link child: { "email", "password" }. Master/standalone only. |
DELETE | /api/user/linked-accounts/{childUserId} | Bearer | Unlink one child. Master only. |
POST | /api/user/linked-accounts/{childUserId}/session | Bearer | Master obtains child user + token for switching. |
GET | /api/user/sessions | Bearer | App sessions (api tokens) for current user only. |
DELETE | /api/user/sessions/{tokenId} | Bearer | Revoke one app session. |
GET | /api/dashboard/summary | Bearer | Single-account KPIs. |
POST | /api/dashboard/summary/aggregate | Bearer | Master: all linked children. Child/standalone: self only. |
Recommended client flow
Master
- Login → read
account_group.linked_accounts. - Add account:
POST /api/user/linked-accountswith child credentials (or use batch login only for initial bootstrap — prefer persisted link API). - Switch to child:
POST /api/user/linked-accounts/{childUserId}/session→ store returned token keyed bychild_user_id. - Combined dashboard:
POST /api/dashboard/summary/aggregatewith master bearer only (noadditional_tokensrequired). - Remove child:
DELETE /api/user/linked-accounts/{childUserId}.
Child
- Login →
role === "child", emptylinked_accounts. - Do not show other linked accounts or accept
additional_tokenson aggregate. - Logout should revoke only the current session (
POST /api/logout) — do not clear other users’ tokens from storage unless the user explicitly removes all accounts.
Logout (important)
POST /api/logout revokes one token. Do not call clearAllSessions() on every logout — remove only the active account from local storage unless the user chooses “log out of all accounts”.
Aggregate response — UI rules
Unchanged from prior delivery:
currency_unified:trueonly if every merged account sharescurrency_id.- Root
wallet_balance: only whencurrency_unifiedistrue. - Per-account buckets:
accounts[].wallet_balance.
Security
- Master/child links are server-side; possession of a stranger’s token does not add them to aggregate.
additional_tokenson aggregate is ignored for masters and standalone; forbidden for children.- Affiliate
master_slaveis a different feature — do not conflate with account switcher groups.
Related docs
- Auth — linked-account routes and
account_groupfields. - Wallet — aggregate semantics.
- Authentication.