---
title: PATCH /api/articles/[id]/sections/[sid]
description: Replace one section's body from Markdown. If the new Markdown splits into several sections, the one becomes several in place. Backs scripto section set.
---

<Note>

The CLI equivalent is `scripto section set <id> <anchor> --file sec.md`.

</Note>

Replaces the section's body from Markdown. If the new Markdown splits into several sections (multiple headings), the one section **becomes several in place**. `sid` is a section anchor.

## Endpoint

```text
PATCH https://scripto.codika.io/api/articles/{id}/sections/{sid}
```

## Auth

`Authorization: Bearer scripto_…`

## Request

| Field | Type | Meaning |
|---|---|---|
| `markdown` | string | **Required**, non-empty. The new section body. |

```json
{ "markdown": "## What changed\n\nRewritten paragraph." }
```

## Response (200)

```json
{
  "success": true,
  "data": {
    "updated": [ { "anchor": "e5f6a7b8", "level": 2, "title": "What changed", "words": 22, "source": "markdown" } ],
    "outline": [ "… the full fresh outline …" ]
  }
}
```

## Errors

| HTTP | `code` | Cause | `nextAction` |
|---|---|---|---|
| 400 | `invalid-argument` | Empty `markdown`, or ambiguous anchor. | Use a longer anchor. |
| 404 | `not-found` | No such article, or no section matches the anchor. | Call GET /outline for current anchors. |
| 401 | `unauthenticated` | Missing or invalid key. | — |

## curl

```bash
curl -sS -X PATCH "https://scripto.codika.io/api/articles/$ID/sections/e5f6a7b8" \
  -H "Authorization: Bearer $SCRIPTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"markdown":"## What changed\n\nRewritten paragraph."}'
```

## Next

- **[DELETE .../sections/[sid]](/api-reference/delete-section)** — remove a section.
- **[POST .../sections/[sid]/move](/api-reference/move-section)** — reorder.
