Linking users
Linking attaches a user's Chartnaut account to their account on your site. The user signs in to Chartnaut themselves and ticks what you may do for them. After that you act for them by your own id: ext:<your ref>.
Make a link
Links are made by your server only, so nobody can attach their own Chartnaut account to someone else's account on your site.
curl https://api.chartnaut.com/partner/v1/links \
-H "Authorization: Bearer cn_partner_live_XXXX" \
-H "Idempotency-Key: 4b0f6c1e-link-8812" \
-H "Content-Type: application/json" \
-d '{
"external_user_ref": "user-8812",
"scopes": ["frame:instant", "sessions:write", "sessions:read", "alerts:read"],
"required_scopes": ["frame:instant", "sessions:write", "sessions:read"]
}'{
"frame_url": "https://terminal.chartnaut.com/embed/yourname?api=https%3A%2F%2Feu-api.chartnaut.com&link=cnl_…",
"connect_url": "https://terminal.chartnaut.com/connect?link=cnl_…",
"expires_at": "2026-11-17T12:30:00Z",
"api_host": "https://eu-api.chartnaut.com"
}Show frame_url in the frame as it is, or send the user to connect_url from your own page. api_host is the API host that made the link; it is already in frame_url. A link works once and expires after 30 minutes. Add "session_id": "ses_…", one of your sessions, to open it as soon as the user is linked.
You can make 20,000 links in any 24 hours, and hold 5 open links per user. Past either you get 422 partner_limit, with details.limit set to links_per_day or open_links_per_user. An unknown scope, a required scope missing from scopes, or a session_id that isn't yours is 400 invalid_request.
What the user sees
A Chartnaut window opens. They sign in, or sign up, and see your name with a ticked list of what you asked for. Scopes in required_scopes are ticked, fixed and marked Required. The others are ticked and can be unticked. They click Connect and the window says they can close it.
Scope | Shown to the user as |
|---|---|
| Open Chartnaut inside your site without signing in each time |
| Create backtest sessions for you; end, lock and unlock them |
| See those sessions: trades, P&L, breaches |
| Create demo accounts for you; lock, unlock and close them |
| See those demo accounts: balance, positions, trades, breaches |
| See your own linked accounts: balances, positions, trades |
| See when your alerts fire |
Chartnaut stores exactly what the user approved. A call that needs a scope they unticked is 403 scope_not_granted, with details.scope naming it. To ask for more later, make a new link with the extra scopes. The user is shown only the new ones.
One to one
Each of your refs links to one Chartnaut account, and each Chartnaut account to one of your refs. The window refuses anything else and changes nothing:
a ref already linked to another Chartnaut account: "This your name account is linked to a different Chartnaut account."
a Chartnaut account already linked to another of your refs: "This Chartnaut account is linked to a different your name account."
A used link says it has already been used, and an old one that it has expired: make a new one.
Check a link
GET /users/ext:user-8812 is the truth: the Chartnaut id, the scopes granted and when they connected. user.connected is a webhook hint that it happened. A user who isn't linked is 404 not_linked.
Unlink
Either side can unlink. The user does it in Chartnaut under Settings → Connected partners; you call DELETE /users/ext:user-8812/connection, which answers {"disconnected": true}. Their frame sign-in ends, the demo accounts you made for them lock, and their sessions stay theirs. You get user.disconnected. When a user deletes their Chartnaut account you get user.deleted: delete what you hold for them.
