Create a script
/scriptsCreates a script and saves its first version. Chartnaut validates the code and pins its dependencies first, and creates nothing if the code has errors.
Scope | Heavy call | Long poll | CLI |
|---|---|---|---|
| Yes | No |
|
Guidance
Call Validate a script first while you iterate. It is free, and a create with errors is refused with
422 script_invalidand nothing is made.To test code without making a script at all, send it inline as
sourceon Create a run. Create a script when you want it in the app, on a chart or in a study.The slug is permanent: it never changes, even when the name does. Indicators and definitions share one set of slugs across Chartnaut, so a slug another account uses answers
409 conflict. Pick another.A
409 conflictsaying you already have a script of this kind with the slug means a previous create landed. This is also what a retry after a dropped connection gets. Carry on with Save a script version.The new script counts toward your plan's library limits. At the cap, or when your plan does not include this kind, the answer is
403 plan_limit. Get usage shows the counts.A study's first version can come back as version 2, because the app saves a starter version when a study is made. Use the returned
versionas your nextbase_version.
Request body
Field | Type | Required | Description |
|---|---|---|---|
| string | Yes |
|
| string | Yes | Lowercase letters and digits in runs joined by single hyphens or underscores, such as |
| array of File | Yes | 1 to 50 files, 2 MB in all. An indicator has exactly one |
| string | No | Display name. Defaults to the slug |
| string | No | Description |
| string | No |
|
| string | No | Recorded on version 1 |
Response
201 with the new Script, without files.
Status codes
Status | Code | Meaning |
|---|---|---|
| - | The script and its first version were created |
|
| The body is not JSON, the slug or visibility is not valid, or |
|
| Your plan does not include this kind of script, or you are at its cap |
|
| You already have a script of this kind with the slug, or the slug is taken on Chartnaut |
|
| The code has errors. |
|
| Past your heavy calls at once. |
|
| The script could not be created. Retry |
