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:
| Field | Type | Meaning |
|---|---|---|
markdown | string | CLI replace-all. Split fresh sections from this Markdown. |
content | string | Editor autosave (HTML). Reconcile into sections, keeping unchanged sections’ Markdown. |
subtitle | string | null | Set 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
| HTTP | code | Cause |
|---|---|---|
| 400 | invalid-argument | Body isn’t JSON; wrong field type; or none of markdown/content/subtitle provided. |
| 401 | unauthenticated | Missing or invalid key. |
| 404 | not-found | No such article, or you don’t own it. |
| 500 | internal | Backend 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
- The section endpoints — edit one part at a time.
- POST …/publish — go live.