Scripto docs
View as Markdown

POST /api/articles/[id]/sections

Insert one Markdown body (which may itself split into several sections) at a chosen place, by anchor. Backs scripto section add.

The CLI equivalent is scripto section add <id> --file part.md [--after|--before <anchor>].

Inserts one Markdown body — which may itself split into several sections if it has multiple headings — at a chosen place. With neither after nor before, the section is appended.

Endpoint

POST https://scripto.codika.io/api/articles/{id}/sections

Auth

Authorization: Bearer scripto_…

Request

FieldTypeMeaning
markdownstringRequired, non-empty. The section body.
afterstring (anchor)Optional. Insert after this section.
beforestring (anchor)Optional. Insert before this section.

Pass at most one of after / before. An anchor is any unique prefix of a section id (see the outline).

{ "markdown": "## Findings\n\nText…", "after": "a1b2c3d4" }

Response (201)

{
  "success": true,
  "data": {
    "added": [ { "anchor": "9c8d7e6f", "level": 2, "title": "Findings", "words": 14, "source": "markdown" } ],
    "outline": [ "… the full fresh outline …" ]
  }
}

added is the outline of the new section(s); outline is the article’s full fresh outline.

Errors

HTTPcodeCausenextAction
400invalid-argumentEmpty markdown; both after and before; or a wrong type.Pass the body as markdown.
400invalid-argumentThe anchor is ambiguous.Use a longer anchor.
404not-foundNo such article, or no section matches the anchor.Call GET /outline for current anchors.
401unauthenticatedMissing or invalid key.

curl

curl -sS -X POST "https://scripto.codika.io/api/articles/$ID/sections" \
  -H "Authorization: Bearer $SCRIPTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"markdown":"## Findings\n\nText…","after":"a1b2c3d4"}'

Next