---
title: "Replace one exact, unique text span in a chapter"
method: POST
path: "/stories/{id}/chapters/{chapterId}/apply-edit"
tags: ["chapters"]
---

# Replace one exact, unique text span in a chapter

`POST /stories/{id}/chapters/{chapterId}/apply-edit`

## Request

- Base URL: `https://aistoryhub.co/api/v1`
- URL: `https://aistoryhub.co/api/v1/stories/{id}/chapters/{chapterId}/apply-edit`
- Auth: HTTP bearer

A literal patch, not an AI rewrite. `old_text` must match exactly one place in the chapter's current content or the call fails instead of guessing. Use find_replace for renaming something everywhere it appears.

## Path parameters

- `id` string, uuid, required
- `chapterId` string, uuid, required

## Request body

- object
  - `old_text` string, required: Exact text to replace, copied verbatim from the chapter. Must be unique in the chapter.
  - `new_text` string, required

## Response `200`

The updated chapter.

- ChapterDetail
  - `id` string, uuid
  - `title` string
  - `type` 'chapter' | 'scene'
  - `order` integer
  - `word_count` integer
  - `updated_at` string, date-time, nullable
  - `content` string

## Other responses

- `400`: The request body or parameters are invalid.
- `401`: Missing, malformed, invalid, revoked, or expired token.
- `403`: The token lacks the scope this endpoint requires.
- `404`: The resource does not exist or you do not own it.
- `429`: Too many requests. Retry after the delay in the `Retry-After` header.

---

[API](https://skmtc.dev/aistoryhub/apis/aistoryhub-api.md) · [All operations](https://skmtc.dev/aistoryhub/apis/aistoryhub-api/llms.txt) · [OpenAPI document](https://skmtc.dev/aistoryhub/apis/aistoryhub-api/revisions/0cfd2c14ae12?raw)
