ChartnautDocs

Save a script version

PUT/scripts/{slug}

Saves the files you send as the script's next version. The save is refused unless base_version is the script's latest version, so an edit made meanwhile in the app or anywhere else is never overwritten.

Scope

Heavy call

Long poll

CLI

scripts:write

Yes

No

chartnaut push

Guidance

  • The usual loop: Get a script with include=source, edit the files, Validate a script, then save with base_version set to the version you read.

  • Send the whole file set every time. A file you leave out is removed from the new version.

  • On 409 version_conflict, someone saved first. error.details.latest_version has the latest number. Read that version, re-apply your change to its files, and save again with the new base_version. Sending the latest number without re-reading overwrites their change in the new version.

  • The version check runs before the code is checked, so a stale base_version answers 409 even when the code also has errors.

  • A save always adds a version; older versions stay readable as slug@N. To go back, save an older version's files on top.

  • The path takes the bare slug only. slug@N answers 400 invalid_request. When one of your studies shares the slug, add kind.

  • It is a heavy call. On 429 busy, wait for Retry-After and send it again. A retry after the first save landed gets 409 version_conflict: read the script to confirm your version is there.

Path parameters

Name

Type

Description

slug

string

Your script's bare slug

Query parameters

Name

Type

Required

Default

Description

kind

string

No

None

indicator, definition or study, when a study shares the slug

Request body

Field

Type

Required

Description

files

array of File

Yes

The whole file set for the new version. 1 to 50 files, 2 MB in all

base_version

integer

Yes

The version your edit started from

change_summary

string

No

Recorded on the new version

Response

200 with the Script at its new version, without files.

Status codes

Status

Code

Meaning

200

-

The new version was saved

400

invalid_request

The path is not a bare slug, the body is not JSON, base_version is missing, or files breaks a file rule

403

forbidden

You cannot change this script

404

not_found

You have no script with that slug

409

version_conflict

The script is past base_version. details.latest_version has the latest

409

conflict

A study shares the slug. Add kind

422

script_invalid

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

429

busy

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