Errors
Every failure carries a stable code, a plain message, and a docs link to its heading on this page. Branch on code, never on the message.
import { ChartnautCommandError, createTerminal } from "@chartnaut/charts";
const terminal = createTerminal(document.getElementById("terminal")!, {});
terminal.orders.buy("NAS100", { risk: "1%", stop: 21480 }).catch((e: unknown) => {
if (!(e instanceof ChartnautCommandError)) throw e;
if (e.is("ruleBlocked") || e.is("lockedByApp")) showBanner(e.message);
else console.warn(e.code, e.reason, e.details, e.docs);
});In the terminal (@chartnaut/charts) a failure is a ChartnautCommandError; on your server (@chartnaut/node) a ChartnautApiError. Both have code, message, reason (why, where the code alone doesn't say), details, docs and is(), which takes the code in either spelling: is("rule_blocked") or is("ruleBlocked"). In dev mode, the terminal's errors also carry fix, a line on what to change.
For limits, details says whose limit it is: { limit, owner, used, cap }, where owner is "user" (the person's Chartnaut plan) or "developer" (yours). Plans and limits
From the terminal
unknown_command
The terminal doesn't take that command: a typo, or an SDK newer than the terminal. The commands it takes are in ready.commands. Check the name, or update the page's terminal to the newest.
invalid_args
An argument is wrong or missing, and the message names it. A size the market doesn't take comes with the market's sizes in details.order_size ({ unit, min, max, step }): see order sizes. A time without an offset is refused too: pass unix seconds, a Date or ISO text with an offset.
not_ready
The terminal isn't ready yet, or the session is still loading. createTerminal and <Terminal> hold calls made before ready for 30 seconds, and send reads again while the session loads, for 15 seconds, so you see this only when it takes longer. With reason: "caught_up", a replay reached the present on a live market and the next bar doesn't exist yet: step again after it closes.
not_allowed
This mode, session, permission or plan doesn't allow it. reason says which:
| Means |
|---|---|
| A partner session whose |
| Backtest only (orders, the replay) or live only (quotes, watchlists) |
| The user didn't grant the permission it needs |
| The session is locked or over |
| The session takes no orders |
| A blind session hides the market |
| Chartnaut doesn't offer that inside an app, such as broker accounts or the journal |
| The person said no on Chartnaut's sheet |
| Another terminal is already on the page |
| Another Connect card is already on the page |
terminal.can("orders.place") answers before you try.
A page holds one terminal at a time. While one is on the page, createTerminal and embed throw not_allowed with reason: "one_terminal_per_page", and a second <Terminal> shows nothing, calls onError and logs the message once. For more charts, use the layout: layout="2x2" puts four charts in the one terminal, interface={onlyCharts} hides everything around them, and linked charts follow each other. Unmounting or destroy() frees the page for the next one, so moving between pages and React's strict mode work as they are.
A Connect card, the sign-in frame from a link's frame_url (linking from your own button), isn't a terminal: one can sit beside the terminal while someone connects. A second Connect card is refused the same way, with reason: "one_connect_card_per_page". A link made with a session opens that session's charts, so it counts as the terminal.
plan_limit
A plan's limit. details.owner is "user" when it is the person's Chartnaut plan (charts at once, history, order flow): they can upgrade. It is "developer" when it is yours (projects, Free-linked users, data): upgrade in Developers → Plan and billing. From the API, also a start date before the user's plan's history. Plans and limits
seat_limit
Your Business seats are full this month (details.limit is seats or pro_seats, with used and cap). A new managed user can't start until you add seats; users already active this month carry on.
rate_limited
Too fast. The terminal takes 20 commands a second and 5 orders; retryAfter is the wait in seconds. createTerminal and <Terminal> wait and send again for up to 15 seconds, and @chartnaut/node waits on Retry-After up to 30 seconds. From the API, details.limit is rate_minute or rate_burst.
rule_blocked
The session's own rules refuse the order: a block after a broken rule, the most positions, or the largest size it allows. The message says which. Show it to the person.
locked_by_app
Your own order lock is on, set with orders.lock(reason). Call orders.unlock() to take orders again.
insufficient_margin
The account hasn't the free margin for that size. Place a smaller size, or close something first.
market_closed
The market is closed, so it takes no orders now.
not_installed
The script isn't in the user's library, and only scripts in their library (or your app's own) can run. Add it from the community, or publish it to your app.
data_not_exportable
This market's data source doesn't let its numbers leave Chartnaut's charts in your app. details names the source and the level needed. Screenshots may still work where the source allows images. capabilities.data_sources lists every source's level, and Symbols and data explains egress.
not_found
No such chart, script, drawing, order or position. From the API: no such object of yours, or an id of the wrong shape. Check the id; useLayout and the list and get calls give the ones that exist.
failed
Anything else; the message says what. Try again. If it keeps failing, send [email protected] the message and the time it happened.
timeout
No reply in time. Reads wait 5 seconds, orders and closes 20, close_all 30. Pass your own timeoutMs for a longer wait. From @chartnaut/node, the request got no answer in time (timeoutMs, default 30 seconds), after its retries.
destroyed
The terminal was taken off the page (destroy(), or the component unmounted) while the call waited.
reloaded
The terminal reloaded while the call waited. Read the state again and carry on: the SDK sends init to the new load, and a resynced event says what was missed.
not_mounted
The frame isn't on the page, so the call had nowhere to go: its iframe was removed from the document. With embed(), keep the element on the page while you send to it.
From your server
These come from the partner API, through @chartnaut/node or your own HTTP calls. plan_limit, seat_limit, rate_limited, not_found and timeout are above.
unauthorized
The key is missing, wrong or revoked (401). Check CHARTNAUT_SECRET_KEY, and that a Test key isn't being used for Live.
forbidden
Your account or role isn't allowed this (403): live frames (frame:live) before they are switched on for your project, or a change your role on the project's team can't make. The message says which.
scope_not_granted
The user didn't grant the permission in details.scope (403). Make a new link that asks for it.
switched_off
That part of the API is paused for your account (403). Write to [email protected].
not_linked
The user isn't linked to your app (404). Send them through a link, or use whenNotLinked in frameRoute: Users.
not_managed
The call is for managed users, and this user is linked: their own Chartnaut account and plan apply (409).
conflict
The external_ref is already used, the same Idempotency-Key is still running, or the session has already ended (409).
expected_count_mismatch
A bulk action by labels matched details.actual, not the count you sent (409). Nothing was done. List the matches and send again.
invalid_request
The request is wrong: a bad field, id or rule, an unknown field, or no Idempotency-Key on a POST (400). details.field or the message names it. A body over 2 MiB is 413.
idempotency_key_reused
That Idempotency-Key was used for a different path or body (422). Use a fresh key for a new request.
partner_limit
One of your project's own limits, named in details.limit (422). Limits and errors lists them.
permission_denied
The key doesn't have the permission this call needs, named in details.permission (403). Use a key that has it, or add it to the key.
internal
Something went wrong on Chartnaut's side (500). Retry with the same Idempotency-Key; @chartnaut/node already has. If it keeps happening, write to [email protected].
network_error
@chartnaut/node got no answer at all, after its retries: check your server can reach api.chartnaut.com.
bad_response
@chartnaut/node got an answer that isn't the API's JSON, such as a proxy's error page.
