ChartnautDocs

Validate a script

POST/scripts/validate

Lints the code, reads its settings and outputs, and resolves its dependencies, without saving or running anything. It uses no compute units, so call it on every edit before you save or run.

Scope

Heavy call

Long poll

CLI

scripts:read

Yes

No

chartnaut validate

Guidance

  • It answers 200 even when the code has errors. Check ok, then read diagnostics: an error stops a save or a run, a warning does not.

  • Create a script and Save a script version run the same checks and refuse code with errors as 422 script_invalid, so fix every error here first.

  • Use interface to see what Chartnaut read from the code: the settings a run accepts and the output ids, event ids and result keys you can filter results by.

  • dependencies lists the versions a save would pin now. A built-in that only runs in the browser comes back as a dependency.browser_only warning: it reads empty in API runs, so pick another.

  • It is a heavy call. While your plan's heavy calls are busy it answers 429 busy; wait for Retry-After (2 seconds) and send it again.

  • Lint and error codes explains each diagnostic code.

Request body

Field

Type

Required

Description

kind

string

Yes

indicator, definition or study

files

array of File

Yes

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

Response

200 with:

Field

Type

Description

ok

boolean

false when any diagnostic is an error

diagnostics

array of Diagnostic

Every finding. [] when there are none

interface

Interface

What Chartnaut read from the code. settings is {} when it could not read it

dependencies

array of Dependency

The versions a save would pin now. Studies always return [] here

Status codes

Status

Code

Meaning

200

-

The checks ran. ok says whether the code passed

400

invalid_request

The body is not JSON, kind is not one of the three, files is empty or breaks a file rule. The message names the problem

429

busy

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

500

internal

The checks could not run. Retry