ChartnautDocs

Users

Every terminal opens for one user. Your server decides who, per person, with @chartnaut/node. Your page's code is the same either way.

Linked users

Managed users

Who they are

People with their own Chartnaut account, any plan, who link it to their account on your site

Accounts you create for your customers, with no Chartnaut sign-up

How they start

Your terminal shows Sign in with Chartnaut; they approve what your app may do

Your server creates them; the terminal opens straight away

Plan

Their own Chartnaut plan

A Free-level or Pro-level seat you choose per user

Their setup

persist: "account" keeps it in their own Chartnaut

No chartbooks: use "device", "none" or your own { load, save }

Needs

Any developer plan

Business

Both get their terminal address from the same call, and your page renders the same <Terminal>.

The route <Terminal> asks

<Terminal> with no frameUrl asks /api/chartnaut/frame on your own site. frameRoute answers it for whoever is signed in:

// app/api/chartnaut/frame/route.ts
import { frameRoute } from "@chartnaut/node";

export const GET = frameRoute({
  getUser: async () => (await auth())?.user.id ?? null,
  whenNotLinked: { link: { scopes: ["frame:instant", "terminal:read", "terminal:write"] } },
});

getUser returns your own id for the person, which becomes ext:<id> on the API, or null when nobody is signed in (the route answers 401). It can also return a Chartnaut id (usr_…), or a whole grant: { user, session } or { user, backtest }.

What happens to someone not linked yet:

whenNotLinked

What they get

"error" (the default)

404 not_linked

{ link: { scopes } }

A link: the terminal shows Sign in with Chartnaut and opens once they approve

"managed"

A managed user is created for your id (Business), then the terminal

Frame addresses are cached in memory until an hour before they expire, so the route calls Chartnaut about once a day per user, not once a visit. When the terminal's sign-in is refused it asks again with ?refresh=1, and the route skips the cache.

With Express use frameRouteExpress, and with a plain Node http server or the Next.js Pages Router frameRouteNode. Both take the same options.

Permissions

A link asks the user for scopes. They see them on the consent screen and can untick any you don't mark required_scopes.

Scope

What the user sees

frame:instant

Open Chartnaut inside your app without signing in each time

terminal:read

See what they do in your app's Chartnaut: charts, scripts, drawings, watchlists and backtest trades

terminal:write

Change their charts, scripts, drawings and watchlists, and place orders in their own backtests

frame:live

Show them live Chartnaut charts inside your app

sessions:write, sessions:read

Create backtests for them, and see their trades, P&L and rule breaks

demo_accounts:write, demo_accounts:read

Create demo accounts for them, and see them

accounts:read

See their own broker accounts: balances, open positions and closed trades, any broker. Read only

alerts:read

See when their Chartnaut alerts go off

Linking has the consent flow in full. You switch on the frame, terminal and sessions scopes yourself. The demo account, broker account and alert scopes work in Test, and need Chartnaut's approval before your app can ask for them in Live: request them on your project's Permissions tab in Developers.

Linking from your own button

import { Chartnaut } from "@chartnaut/node";

const cn = new Chartnaut(); // reads CHARTNAUT_SECRET_KEY

export async function connectUrl(userId: string, email: string) {
  const link = await cn.links.create({
    external_user_ref: userId,
    scopes: ["frame:instant", "terminal:read", "terminal:write"],
    account_label: email,
  });
  return link.connect_url; // or link.frame_url in an iframe
}

account_label is your name for the person, shown masked beside their Chartnaut account on the consent screen, so nobody links someone else's account by mistake.

Managed users

import { Chartnaut } from "@chartnaut/node";

const cn = new Chartnaut();

export async function openFor(customerId: string) {
  await cn.users.create({ external_ref: customerId, name: "Sam" });
  await cn.users.update(`ext:${customerId}`, { level: "pro", features: { order_flow: false } });
  const { frame_url } = await cn.frames.url({ user: `ext:${customerId}`, persist: "none" });
  return frame_url;
}

A managed user is a seat on your Business bundle, at Free level or Pro level. You can switch features off per user at no charge. Seats count only when the user is active that month. Plans and limits

Backtests by key

Users can't start a backtest inside your terminal: your server gives them one. Name it with your own key. The first time, Chartnaut creates it (a normal backtest owned by the user, tagged with your app so your page may trade in it); every later time, it opens the same one.

import { frameRoute } from "@chartnaut/node";

export const GET = frameRoute({
  getUser: async () => (await auth())?.user.id ?? null,
  frameOptions: (req) => ({
    backtest: { key: `drill-${new URL(req.url).searchParams.get("drill")}`, start: "2026-09-01", end: "2026-09-05" },
  }),
});

Use a new key for a new attempt. The user's plan still applies: a start before their plan's history is refused with plan_limit.

For competitions and other sessions with rules, create a partner session on your server with cn.sessions.create and open it with { user, session }. See Sessions and Rules.

Their accounts

Demo accounts you create for a user, and the user's own broker accounts you can read (balances, open positions and closed trades), are on Accounts.

The client

new Chartnaut({ key }) wraps every partner API route, with retries, typed errors and an Idempotency-Key on every POST:

Area

Methods

cn.users

create (managed), get, list, iterate, update (managed), export, getExport, delete (managed), disconnect (linked), alertFires

cn.links

create

cn.frames

url, forget

cn.sessions

create, createBatch, list, iterate, get, update, trades, breaches, actions, end, lock, unlock

cn.accounts

Demo accounts: create, list, get, trades, lock, unlock, closeAll and more. The user's own: listUserAccounts, getUserAccount, positions, trades

cn.scripts

publish, list, unpublish

cn.webhooks

verify, verifyRequest, test

Every failure is a ChartnautApiError with a code from Errors. The full partner API is in the API reference.