ChartnautDocs

Add to your library

POST/library/{author}/{slug}

Adds another author's indicator or definition to your library, together with the scripts it reads, as Add to library does in the app. Their script runs for you only once it is in your library, so call this before you run it.

Scope

Heavy call

Long poll

CLI

scripts:write

No

No

chartnaut library add

Guidance

  • Adding is a two-step agreement. Call Check what a script needs, show the person what will be added, and only if they agree send this request with confirm listing every ref in its confirm. A request whose confirm leaves any of them out adds nothing and answers 409 confirmation_required with the list, so you can show it and ask.

  • Everything it needs is added together, or nothing is. You cannot add the script without the scripts it reads.

  • Adding never copies anything. Each script stays its author's, picks up their edits, and you can take it out again with Remove from your library.

  • When something it needs is not shared with you, nothing is added: 409 not_shared, with details.cannot_add naming it.

  • Your own scripts, Chartnaut's built-ins and scripts you already added are usable as they are. Adding one answers 200 with added: false and the reason, and changes nothing, so a retry is safe.

  • Studies cannot be added: 409 not_installable. Only your own studies run.

  • A ref in confirm that the script does not need is ignored and reported in skipped with the reason not_a_dependency. @N on a confirm entry is dropped; @N in the path is refused with 400.

Path parameters

Name

Type

Description

author

string

The author's username, in any letter case

slug

string

The script's slug, without @N

Query parameters

Name

Type

Required

Default

Description

kind

string

No

None

indicator or definition, when the author has both with that slug

Request body

Optional. With no body, or an empty confirm, only a script that needs nothing else is added.

Field

Type

Required

Description

confirm

array of string

When it needs other scripts

The refs the person agreed to add: every ref in confirm from Check what a script needs

Response

201 when it was added, 200 when it was usable already. Both carry these fields.

Field

Type

Description

added

boolean

true when this call added it

root

object

The script: ref, kind, name and status, with author when it was added

added_with

array of string

The refs added along with it. [] when none

skipped

array of object

confirm entries that were not added, each with ref and reason: not_a_dependency, or the status that made it unnecessary, such as installed

reason

string

Only when added is false: why nothing changed, such as This is already in your library.

Status codes

Status

Code

Meaning

201

-

Added, with everything in added_with

200

-

Already usable: yours, a built-in, or already in your library. Nothing changed

400

invalid_request

The body is not JSON, the path has @N, or kind is not one of its values

404

not_found

No script by that author and slug that you can see

409

confirmation_required

It needs scripts that confirm does not list. Nothing was added. details has needs, confirm and missing

409

not_shared

Something it needs is not shared with you, so it cannot be added. details.cannot_add names it

409

not_installable

It is a study. Studies cannot be added to a library

409

conflict

The author has more than one script with that slug. Add kind