Run a script on one instrument and window
/runs- Base URL
https://api.chartnaut.com/v1- Auth
- Bearer key
- Operation ID
createRun
One verb for all three kinds. Pass script (a saved ref) or source
(inline, saves nothing). A study over several instruments is several
runs; the CLI fans out.
Limits:
- Inline
sourcesupports indicators and definitions. Save a study first, then run it by ref. - Studies run only from your own scripts. Indicators and definitions can
also run by
author/slug, without their source, once they are in your library (addToLibrary). Otherwise 409not_in_library, withdetails{ref, add, needs, cannot_add, confirm}. Your own scripts andchartnaut/built-ins never need adding. - A study whose declared definitions are not all yours, built-in or in your
library is refused before anything runs: 409
not_in_librarywithdetails.definitions(one entry per definition to add), or 409not_sharedwithdetails.cannot_addwhen one is not shared with you. - One run's window holds at most 50,000 bars at the run's timeframe.
- Runs execute in the account's run slots (plan: Free 1, Pro 3, plus
1 per compute concurrency add-on), shared with the account's own app sessions.
Queued+running API runs are capped at slots + 4 (429
busy). - Indicator and definition results are kept for 7 days.
- A definition run keeps at most 10,000 events;
summary.events_totalcounts all of them. - The window is clamped to your plan's history and ends on a closed bar.
With wait > 0 the call blocks until the run finishes or wait
elapses, then returns the run in whatever state it is in. 202 means
still running: poll getRun or use a webhook.
Headers#
Idempotency-KeystringAny unique string. A retry with the same key within 24h returns the first response instead of creating a second script, version or run.
Request bodyapplication/json#
scriptstring · ScriptRefslug or slug@N for your own scripts; author/slug or
author/slug@N for library scripts; chartnaut/slug for built-ins
(which always run their latest version).
sourceobject · ScriptSourceShow fields
Show item fields
pathstringRequiredcodestringRequiredentrybooleanExactly one file is the entry. Indicators have one file, always the entry.
instrumentstringRequiredCanonical or short symbol.
Exactly one of {from,to}, last or bars. Warmup is fetched before
the window automatically and never counted in results. Clamped to the
plan's historical depth.
Show fields
fromstring (date-time)tostring (date-time)Defaults to now.
laststringbarsintegersettingsobjectOverrides; anything omitted uses the script's default.
studyobjectStudy only.
Show fields
event_filterobjectRestrict to events matching these payload values.
waitintegerSeconds to block for completion.
labelstringFree text, shown in the app.
One of
Option 1any
Option 2any
Responses#
200OKapplication/json
Finished within wait (succeeded, failed or cancelled).
idstringkindstring · ScriptKindscriptstringThe resolved ref that ran (vwap-reclaim@3), or inline.
instrumentstringThe instrument's display symbol (short in /instruments).
timeframestring · TimeframewindowobjectThe resolved window after clamping.
Show fields
fromstring (date-time)tostring (date-time)settingsobjectstatusstring · RunStatusprogressobjectShow fields
pctnumberphasestringfailureobjectNullableShow fields
kindstring · FailureKindWhy a run failed. retryable on the run says whether trying again can help.
messagestringretryablebooleandiagnosticsarray of object · DiagnosticShow item fields
severitystringRequiredcodestringmessagestringRequiredpathstringlineintegersettingstringThe setting a finding is about, if any.
summaryobjectNullableSmall, always inline once finished.
indicator: {bars, outputs:{id:{last, min, max, count}}, warnings?, errors?}
definition: {bars, events_total, events_kept?, by_event:{id:count}, warnings?, errors?}
study: {events_processed}
errors are runtime errors on some bars; the run still produced results.
consolearray of objectNullableThe first 50 console lines the script printed. null until the run has finished, or when it printed nothing.
Show item fields
levelstringmessagestringtimestring (date-time)usageobjectShow fields
barsintegerBars evaluated, warmup and dependencies included.
compute_unitsnumberapp_urlstring (uri)NullableStudy runs only; indicator and definition runs are not stored in the app.
results_expire_atstring (date-time)created_atstring (date-time)started_atstring (date-time)Nullablefinished_atstring (date-time)Nullable202Acceptedapplication/json
Accepted, still queued or running.
idstringkindstring · ScriptKindscriptstringThe resolved ref that ran (vwap-reclaim@3), or inline.
instrumentstringThe instrument's display symbol (short in /instruments).
timeframestring · TimeframewindowobjectThe resolved window after clamping.
Show fields
fromstring (date-time)tostring (date-time)settingsobjectstatusstring · RunStatusprogressobjectShow fields
pctnumberphasestringfailureobjectNullableShow fields
kindstring · FailureKindWhy a run failed. retryable on the run says whether trying again can help.
messagestringretryablebooleandiagnosticsarray of object · DiagnosticShow item fields
severitystringRequiredcodestringmessagestringRequiredpathstringlineintegersettingstringThe setting a finding is about, if any.
summaryobjectNullableSmall, always inline once finished.
indicator: {bars, outputs:{id:{last, min, max, count}}, warnings?, errors?}
definition: {bars, events_total, events_kept?, by_event:{id:count}, warnings?, errors?}
study: {events_processed}
errors are runtime errors on some bars; the run still produced results.
consolearray of objectNullableThe first 50 console lines the script printed. null until the run has finished, or when it printed nothing.
Show item fields
levelstringmessagestringtimestring (date-time)usageobjectShow fields
barsintegerBars evaluated, warmup and dependencies included.
compute_unitsnumberapp_urlstring (uri)NullableStudy runs only; indicator and definition runs are not stored in the app.
results_expire_atstring (date-time)created_atstring (date-time)started_atstring (date-time)Nullablefinished_atstring (date-time)Nullable409Conflictapplication/json
not_in_library: another author's script, or a definition your study declares, is not in
your library. not_shared: your study declares a definition that is not shared with you.
conflict: one of your studies shares the slug with an indicator or definition.
errorobjectRequiredShow fields
codestringRequiredStable. Branch on this, never on message.
messagestringRequireddetailsobjectdocs_urlstring (uri)request_idstring422Unprocessableapplication/json
The script does not lint, link or derive. Nothing was saved or run.
Includes Error
errorobjectRequiredShow fields
codestringRequiredStable. Branch on this, never on message.
messagestringRequireddetailsobjectdocs_urlstring (uri)request_idstringdiagnosticsarray of object · DiagnosticShow item fields
severitystringRequiredcodestringmessagestringRequiredpathstringlineintegersettingstringThe setting a finding is about, if any.
ErrorAny other statusapplication/json
Error.
errorobjectRequiredShow fields
codestringRequiredStable. Branch on this, never on message.
messagestringRequireddetailsobjectdocs_urlstring (uri)request_idstring