ChartnautDocs

Create a script

POST/scripts

Creates 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

scripts:write

Yes

No

chartnaut push

Guidance

  • Call Validate a script first while you iterate. It is free, and a create with errors is refused with 422 script_invalid and nothing is made.

  • To test code without making a script at all, send it inline as source on 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 conflict saying 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 version as your next base_version.

Request body

Field

Type

Required

Description

kind

string

Yes

indicator, definition or study

slug

string

Yes

Lowercase letters and digits in runs joined by single hyphens or underscores, such as my-ema. Upper case is lowered. Keep it to 128 characters so paths can address it

files

array of File

Yes

1 to 50 files, 2 MB in all. An indicator has exactly one

name

string

No

Display name. Defaults to the slug

description

string

No

Description

visibility

string

No

private (the default) or public

change_summary

string

No

Recorded on version 1

Response

201 with the new Script, without files.

Status codes

Status

Code

Meaning

201

-

The script and its first version were created

400

invalid_request

The body is not JSON, the slug or visibility is not valid, or files breaks a file rule

403

plan_limit

Your plan does not include this kind of script, or you are at its cap

409

conflict

You already have a script of this kind with the slug, or the slug is taken on Chartnaut

422

script_invalid

The code has errors. diagnostics lists them; nothing was created

429

busy

Past your heavy calls at once. Retry-After: 2

500

internal

The script could not be created. Retry