Scripto docs
View as Markdown

PATCH /api/articles/[id]

Update an article's body and/or subtitle. Three body shapes — markdown (CLI replace-all), content (editor HTML), and subtitle — all routed through the section model.

The CLI equivalent is scripto articles update <id> --file draft.md, which sends markdown. To edit just one part, prefer the section endpoints — they keep your context small.

Updates a body and/or the subtitle (owner-scoped). All body writes route through the section model, so the invariant content === concat(sections.html) always holds, and title / coverImage / wordCount are re-derived server-side whenever a body is present.

Endpoint

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

Auth

Authorization: Bearer scripto_…

Request

Send at least one of three fields:

FieldTypeMeaning
markdownstringCLI replace-all. Split fresh sections from this Markdown.
contentstringEditor autosave (HTML). Reconcile into sections, keeping unchanged sections’ Markdown.
subtitlestring | nullSet or clear the dek. No body change.

If both markdown and content are sent, markdown wins.

{ "markdown": "# Our launch\n\nWhat changed…\n\n## Why it matters\n\n…" }

Response (200)

{ "success": true, "data": { "article": { "id": "0a1b2c3d-…", "title": "Our launch", "…": "…" } } }

Errors

HTTPcodeCause
400invalid-argumentBody isn’t JSON; wrong field type; or none of markdown/content/subtitle provided.
401unauthenticatedMissing or invalid key.
404not-foundNo such article, or you don’t own it.
500internalBackend error.

curl

# Set the subtitle only.
curl -sS -X PATCH "https://scripto.codika.io/api/articles/$ID" \
  -H "Authorization: Bearer $SCRIPTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"subtitle":"What changed and why"}'

Next