Create a backtest session for a user
/sessions- Base URL
https://api.chartnaut.com/partner/v1- Auth
- Bearer key
- Operation ID
createSession
Needs sessions:write. The session follows the user's plan: a day outside the plan's window
or history, or a market the user's account can't use (e.g. futures without futures access),
is 422 plan_limit with the reason in message and details.reason. 10 active (active or
locked) sessions per user and 10,000 per partner (422 partner_limit, details.limit
active_sessions_per_user or active_sessions). rules are copied onto the session and
fixed after that. A reused external_ref is 409 conflict with details.existing_id. A
bad field is 400 invalid_request with details.field (e.g. instruments[1], start,
labels.cohort); an unknown market is 400 on instruments[i]; a refusal by the
session start itself (e.g. no data for the day) is 400 with no details. Answers 201
with the full session, as GET /sessions/{session} gives it.
Headers#
Idempotency-KeystringRequiredRequired on every POST (400 invalid_request without it): any unique string of 1–255
visible ASCII characters (a UUID is ideal). Keys are per environment. A retry with the same
key, path and body within 24 hours returns the first response with Idempotent-Replayed: true and runs nothing. The same key with a different path or body is 422 idempotency_key_reused; while the first request is still running, 409 conflict. 5xx
and 429 answers are not stored, so a retry with the same key runs again.
Request bodyapplication/json#
userstringRequiredusr_<id> or ext:<ref>.
namestringShown to the user in Chartnaut. Defaults to "<your partner name> session".
instrumentsarray of stringRequiredMarkets by symbol as in the Chartnaut catalogue (e.g. EURUSD, NAS100); an alias or Chartnaut's numeric instrument id also works. No market twice. Read back as display symbols. The session's symbol picker is held to these.
startstringWhere the replay begins: a UTC date (2026-09-01, from 00:00 UTC) or an RFC 3339 time. In the past, and inside the user's plan window. Required unless you give day.
endstringOptional. Where the replay stops: a UTC date (through the end of that day) or an RFC 3339 time, after start and not in the future. Leave it out and the session plays on to the latest market data.
daystringShorthand for exactly one day: a UTC date (the whole UTC day) or an RFC 3339 time (the 24 hours from it). Give start (and end) or day, not both.
starting_balancenumberRequiredRequired; there is no default.
currencystringA three-letter code; read back in upper case.
leveragenumbercommissionobject · CommissionCharged per side on every market: fixed per unit (lot, contract, share; 0–1,000), or percentage of the side's notional (0–100).
Show fields
typestringRequiredvaluenumberRequiredtime_cap_minutesintegerMinutes of play the user gets, from when a page first opens the session, before it ends on its own. 0: no cap.
blindbooleanHide the market, the date and prices: your setting; a display mode, not a security boundary.
allow_skipbooleanWhether the user may skip forward (jump) in time.
rulesone of 2 types · RulesInputInline rules, copied onto the session or account at create and fixed after that. Either a
list of rules, or { "day_reset": {...}, "rules": [...] } to move the trading day (one per
rule set; default 17:00 America/New_York, the FX rollover, which follows US daylight saving).
At most 50 rules. Checked in whole cents.
on_breach:
record(default): store the breach and sendrule.breached; nothing else.block_order: also refuse new orders (exits stay allowed). Adaily_lossblock lasts until the next day reset; any other rule's lasts for good. The status staysactive.close_and_end: also close everything and end it; the status becomesbreached.
A profit target has no on_breach: reaching it closes everything and ends as
completed_to_target. Every breach acts as its rule says. Only if Chartnaut pauses rule
actions for you in an emergency are breaches stored with action_applied: false, and
nothing is done.
Show options
One of
array of object · Rule
idstringYour name for the rule; defaults to its type (then type_2, …). Breaches name it.
typestringRequiredOne of
daily_loss
type"daily_loss"RequiredAn amount (a bare number, or {"amount": n}), or {"percent": n} of the starting balance.
Show options
One of
number
With amount
amountnumberRequiredOther fields are refused.
With percent
percentnumberRequiredOther fields are refused.
basisstringMeasured from the start-of-day balance or equity.
on_breachstringmax_drawdown
type"max_drawdown"RequiredAn amount (a bare number, or {"amount": n}), or {"percent": n} of the starting balance.
Show options
One of
number
With amount
amountnumberRequiredOther fields are refused.
With percent
percentnumberRequiredOther fields are refused.
modestringfixed from the starting balance; trailing from the peak.
peakstringTrailing only: what the peak follows (equity is updated on every price change).
stop_at_starting_balancebooleanTrailing only: the floor stops rising once it reaches the starting balance.
on_breachstringmax_position_size
type"max_position_size"Requiredlimitone of 2 typesRequiredThe largest position per market, in units as the platform shows them (lots, contracts, coins, shares), up to three decimals: a number or {"units": n}.
Show options
One of
number
With units
unitsnumberRequiredon_breachstringmax_open_positions
type"max_open_positions"Requiredlimitone of 2 typesRequiredShow options
One of
integer
With count
countintegerRequiredon_breachstringprofit_target
type"profit_target"RequiredAn amount (a bare number, or {"amount": n}), or {"percent": n} of the starting balance.
Show options
One of
number
With amount
amountnumberRequiredOther fields are refused.
With percent
percentnumberRequiredOther fields are refused.
basisstringReached when equity hits it, or when an exit brings the closed balance to it. The recorded result is the closed balance.
slippage
type"slippage"RequiredticksintegerRequiredEvery market and stop fill moves this many ticks against the trader. Limits never slip. A cost, never a breach.
RuleSet
The canonical form, returned on read with every default filled in and every id present.
day_resetobjectShow fields
timestringtzstringAn IANA time zone.
Other fields are refused.
rulesarray of object · RuleShow item fields
idstringYour name for the rule; defaults to its type (then type_2, …). Breaches name it.
typestringRequiredOne of
daily_loss
type"daily_loss"RequiredAn amount (a bare number, or {"amount": n}), or {"percent": n} of the starting balance.
Show options
One of
number
With amount
amountnumberRequiredOther fields are refused.
With percent
percentnumberRequiredOther fields are refused.
basisstringMeasured from the start-of-day balance or equity.
on_breachstringmax_drawdown
type"max_drawdown"RequiredAn amount (a bare number, or {"amount": n}), or {"percent": n} of the starting balance.
Show options
One of
number
With amount
amountnumberRequiredOther fields are refused.
With percent
percentnumberRequiredOther fields are refused.
modestringfixed from the starting balance; trailing from the peak.
peakstringTrailing only: what the peak follows (equity is updated on every price change).
stop_at_starting_balancebooleanTrailing only: the floor stops rising once it reaches the starting balance.
on_breachstringmax_position_size
type"max_position_size"Requiredlimitone of 2 typesRequiredThe largest position per market, in units as the platform shows them (lots, contracts, coins, shares), up to three decimals: a number or {"units": n}.
Show options
One of
number
With units
unitsnumberRequiredon_breachstringmax_open_positions
type"max_open_positions"Requiredlimitone of 2 typesRequiredShow options
One of
integer
With count
countintegerRequiredon_breachstringprofit_target
type"profit_target"RequiredAn amount (a bare number, or {"amount": n}), or {"percent": n} of the starting balance.
Show options
One of
number
With amount
amountnumberRequiredOther fields are refused.
With percent
percentnumberRequiredOther fields are refused.
basisstringReached when equity hits it, or when an exit brings the closed balance to it. The recorded result is the closed balance.
slippage
type"slippage"RequiredticksintegerRequiredEvery market and stop fill moves this many ticks against the trader. Limits never slip. A cost, never a breach.
Other fields are refused.
external_refstringYour id for the session; unique per partner (409 conflict with details.existing_id on reuse).
labelsmap of string · LabelsA session's labels: up to 20; keys 1–64 letters, digits or _ . : -; string values up to 200 characters. Never interpreted; filter on them with label.<key>=<value>.
page_controlstring · PageControlWhat the developer's page may drive in this session through the terminal SDK: none (the default), replay (play, pause, step, speed, jump, hold) or replay_and_orders (also place orders).
Other fields are refused.
Responses#
201Createdapplication/json
Created.
Headers
Idempotent-Replayedstringtrue when this is the stored response of an earlier request with the same Idempotency-Key.
Body
Includes SessionCommon
idstringRequireduserstringRequiredexternal_user_refstringYour ref for the user; left out when the user is no longer linked.
external_refstringRequiredNullableA session's labels: up to 20; keys 1–64 letters, digits or _ . : -; string values up to 200 characters. Never interpreted; filter on them with label.<key>=<value>.
namestringRequiredactive; locked (by you or Chartnaut; a demo account also locks when its user unlinks);
and the final ones: ended (you, the user, Chartnaut or a session's time cap ended it;
status_reason says who), breached (a close_and_end rule fired),
completed_to_target (the profit target was reached; everything was closed). A
block_order breach refuses new orders but leaves the status active.
status_reasonstringRequiredWho set the status (e.g. partner, admin, rule, time_cap); empty when nobody has.
created_atstring (date-time)Requiredlocked_atstring (date-time)Left out when not locked.
ended_atstring (date-time)Left out until it ends.
replay_timestring (date-time)RequiredNullableThe replay clock as last saved.
locked_replay_timestring (date-time)Where a lock or end froze the replay. Left out otherwise.
startstring (date-time)Where the replay begins.
endstring (date-time)NullableWhere the replay stops; null when the session plays on to the latest data.
dayobjectRequiredDeprecatedThe same window as start and end, under its older name.
Show fields
startstring (date-time)Requiredendstring (date-time)RequiredNullableinstrumentsarray of stringRequiredA decimal amount in the account currency (USD), at most two decimal places.
currencystringRequiredleveragenumberRequiredcommissionobject · CommissionCharged per side on every market: fixed per unit (lot, contract, share; 0–1,000), or percentage of the side's notional (0–100).
Show fields
typestringRequiredvaluenumberRequiredtime_cap_minutesintegerLeft out when there is no cap.
opened_atstring (date-time)When a page first opened it (the time cap runs from here). Left out until then.
time_cap_ends_atstring (date-time)Left out without a cap or before the first open.
blindbooleanRequiredallow_skipbooleanRequiredWhat the developer's page may drive in this session through the terminal SDK: none (the default), replay (play, pause, step, speed, jump, hold) or replay_and_orders (also place orders).
accountobjectRequiredThe account at replay_time.
Show fields
currencystringRequiredA decimal amount in the account currency (USD), at most two decimal places.
A decimal amount in the account currency (USD), at most two decimal places.
A decimal amount in the account currency (USD), at most two decimal places.
A decimal amount in the account currency (USD), at most two decimal places.
valued_atstring (date-time)The replay time open positions were marked at.
unpricedintegerOpen positions that could not be priced at the replay time (equity then leaves them out). Left out when 0.
open_positionsarray of object · SessionPositionLeft out when there are none.
Show item fields
idintegerRequiredinstrumentstringRequiredsidestringRequiredquantitynumberRequiredentry_pricenumberRequiredopened_atstring (date-time)RequiredReplay time.
marknumberLeft out when it couldn't be priced.
unrealized_pnlnumberLeft out when it couldn't be priced.
unpricedstringWhy it couldn't be priced.
working_ordersintegerLeft out when 0.
Closed trades only.
Show fields
tradesintegerRequiredwinsintegerRequiredlossesintegerRequiredwin_ratenumberRequiredgross_profitnumberRequiredgross_lossnumberRequirednet_pnlnumberRequiredprofit_factornumberRequiredNullableaverage_winnumberRequiredaverage_lossnumberRequiredlargest_winnumberRequiredlargest_lossnumberRequiredmax_drawdownnumberRequiredmax_drawdown_pctnumberRequiredrulesobject · RuleSetThe canonical form, returned on read with every default filled in and every id present.
Show fields
day_resetobjectShow fields
timestringtzstringAn IANA time zone.
rulesarray of object · RuleShow item fields
idstringYour name for the rule; defaults to its type (then type_2, …). Breaches name it.
typestringRequiredOne of
daily_loss
type"daily_loss"RequiredAn amount (a bare number, or {"amount": n}), or {"percent": n} of the starting balance.
Show options
One of
number
With amount
amountnumberRequiredWith percent
percentnumberRequiredbasisstringMeasured from the start-of-day balance or equity.
on_breachstringmax_drawdown
type"max_drawdown"RequiredAn amount (a bare number, or {"amount": n}), or {"percent": n} of the starting balance.
Show options
One of
number
With amount
amountnumberRequiredWith percent
percentnumberRequiredmodestringfixed from the starting balance; trailing from the peak.
peakstringTrailing only: what the peak follows (equity is updated on every price change).
stop_at_starting_balancebooleanTrailing only: the floor stops rising once it reaches the starting balance.
on_breachstringmax_position_size
type"max_position_size"Requiredlimitone of 2 typesRequiredThe largest position per market, in units as the platform shows them (lots, contracts, coins, shares), up to three decimals: a number or {"units": n}.
Show options
One of
number
With units
unitsnumberRequiredon_breachstringmax_open_positions
type"max_open_positions"Requiredlimitone of 2 typesRequiredShow options
One of
integer
With count
countintegerRequiredon_breachstringprofit_target
type"profit_target"RequiredAn amount (a bare number, or {"amount": n}), or {"percent": n} of the starting balance.
Show options
One of
number
With amount
amountnumberRequiredWith percent
percentnumberRequiredbasisstringReached when equity hits it, or when an exit brings the closed balance to it. The recorded result is the closed balance.
slippage
type"slippage"RequiredticksintegerRequiredEvery market and stop fill moves this many ticks against the trader. Limits never slip. A cost, never a breach.
breachesobjectRequiredShow fields
countintegerRequiredlastobject · BreachThe newest breach. Left out when there are none.
Show fields
idstringRequiredrule_idstringRequiredrule_typestringRequiredperiodstringThe trading day (YYYY-MM-DD) for daily rules.
limitnumberRequiredThe rule's limit, in unit.
valuenumberRequiredWhat was observed, in unit.
unitstringRequiredThe same for sessions and demo accounts: money (a decimal in the account currency)
for money rules, units (lots, contracts, coins or shares, up to three decimals) for
max_position_size, count (a whole number) for max_open_positions.
atstring (date-time)RequiredThe crossing: replay time for backtests (the bar's time), the exact price change for demo accounts.
at_precisionstringRequiredbetween: across a gap in our price records, the crossing was between window_start and window_end.
window_startstring (date-time)window_endstring (date-time)pricesobjectRequiredNullableDemo accounts: the bid/ask by market at the crossing. Sessions: {}.
actionstringRequiredaction_appliedbooleanRequiredfalse when Chartnaut has paused rule actions for you (an emergency stop): the breach is stored and nothing is done.
detected_atstring (date-time)Requireddetected_bystringRequiredWhere it was found: client or replay for sessions; sweep (a price change) or event (a fill, close or adjustment) for demo accounts.
ErrorAny other statusapplication/json
Error. Every response to a request whose key checked out, errors included, carries
RateLimit-Limit (requests a minute), RateLimit-Remaining and RateLimit-Reset (seconds
until the minute resets). A 401, the 403 switched_off when the whole API is off for
you, and the 429 for too many bad keys from one IP come before that check and carry
none. A 429 also carries Retry-After (seconds).
Headers
RateLimit-LimitintegerRateLimit-RemainingintegerRateLimit-ResetintegerRetry-AfterintegerBody
Show fields
codestringRequiredStable. Branch on this, never on message.
| Code | Status | Meaning |
|---|---|---|
unauthorized |
401 | missing, unknown or revoked key (no RateLimit headers) |
scope_not_granted |
403 | the user didn't grant details.scope |
forbidden |
403 | your partner account isn't allowed this (details.reason, e.g. no_access for frame:live when live mode isn't enabled for you; details.scope) |
permission_denied |
403 | this key lacks the key permission the call needs (details.permission, e.g. users:export; details.reason: "key_permission"): use a key that has it, or add it in the partner portal |
not_managed |
409 | the call is for managed users only, and this user is linked (their own Chartnaut account and plan apply; details.reason: "not_managed") |
switched_off |
403 | this part of the API is paused for you (everything, writes, frames, links, demo account creation, bulk actions); contact [email protected] |
not_linked |
404 | the user isn't linked to you (details.user when the user was named in the request) |
not_found |
404 | no such object for you; an id of the wrong type or shape is this too |
conflict |
409 | external_ref already used (sessions: details.existing_id; accounts: details.field); the same Idempotency-Key still running; lock or unlock on an ended session |
expected_count_mismatch |
409 | a bulk action matched a different number (details.expected, details.actual) |
invalid_request |
400 | malformed body or unknown field (named in message, no details), a bad field (details.field where the endpoint names it), bad id, missing Idempotency-Key, invalid rules. Also 413 for a body over 2 MiB |
idempotency_key_reused |
422 | the Idempotency-Key was used with a different path or body |
plan_limit |
422 / 403 | the user's Chartnaut plan doesn't allow it (details.reason), or your developer plan's cap (details.owner: "developer", details.limit: apps (an app past your plan's count after a downgrade takes no new users), free_linked, managed_users, data; with used, cap). No auto top-up: upgrade on the Developers page |
seat_limit |
403 | your Business seats are full this month (details.limit seats or pro_seats, used, cap): a new managed user can't start until you add seats; users active this month carry on |
partner_limit |
422 | one of your partner limits (details.limit, and for demo accounts details.max) |
rate_limited |
429 | your rate limit: details.limit is rate_minute or rate_burst. Also, with no details and Retry-After: 60, any call from an IP that sent 30 bad keys this minute, good keys included. See Retry-After |
internal |
500 | retry; if it persists contact [email protected] |
messagestringRequireddetailsobject