AIStoryHub Chapters API

Chapters and scenes within a story.

Operations 7

GET /stories/{id}/chapters List a story's chapters and scenes #
POST /stories/{id}/chapters Create a chapter or scene #
GET /stories/{id}/chapters/{chapterId} Fetch one chapter with its content #
PATCH /stories/{id}/chapters/{chapterId} Update a chapter or scene's title, content, or position #
DELETE /stories/{id}/chapters/{chapterId} Delete a chapter or scene #
POST /stories/{id}/chapters/{chapterId}/apply-edit Replace one exact, unique text span in a chapter #
POST /stories/{id}/manuscript/find-replace Deterministic find/replace across one chapter or the whole manuscript #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/aistoryhub-co:aistoryhub-co-chapters-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

aistoryhub-co-chapters-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: AIStoryHub Chapters API
  version: 1.0.0
  description: A REST API for reading and creating stories and chapters on AIStoryHub outside the app. Authenticate with a scoped bearer token created under Settings, Developer API. Scopes are explicit, so write access does not imply read access.
  contact:
    url: https://aistoryhub.co/developers
  termsOfService: https://aistoryhub.co/terms
servers:
- url: https://aistoryhub.co/api/v1
security:
- bearerAuth: []
tags:
- name: chapters
  description: Chapters and scenes within a story.
paths:
  /stories/{id}/chapters:
    get:
      operationId: listChapters
      tags:
      - chapters
      summary: List a story's chapters and scenes
      description: Content is omitted from list results; fetch a single chapter for its `content`.
      x-required-scope: stories:read
      parameters:
      - $ref: '#/components/parameters/StoryId'
      responses:
        '200':
          description: The story's chapters and scenes, in manuscript order.
          content:
            application/json:
              schema:
                type: object
                required:
                - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/ChapterSummary'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
    post:
      operationId: createChapter
      tags:
      - chapters
      summary: Create a chapter or scene
      description: Defaults to the end of the manuscript unless order_index is given. Leave content empty to draft into it afterward with /ai/generate.
      x-required-scope: stories:write
      parameters:
      - $ref: '#/components/parameters/StoryId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - title
              properties:
                title:
                  type: string
                type:
                  type: string
                  enum:
                  - chapter
                  - scene
                  default: chapter
                content:
                  type: string
                parent_id:
                  type: string
                  format: uuid
                order_index:
                  type: integer
                  minimum: 0
      responses:
        '201':
          description: The created chapter.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChapterDetail'
        '400':
          $ref: '#/components/responses/InvalidRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
  /stories/{id}/chapters/{chapterId}:
    get:
      operationId: getChapter
      tags:
      - chapters
      summary: Fetch one chapter with its content
      x-required-scope: stories:read
      parameters:
      - $ref: '#/components/parameters/StoryId'
      - name: chapterId
        in: path
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: The chapter, including its content.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChapterDetail'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
    patch:
      operationId: updateChapter
      tags:
      - chapters
      summary: Update a chapter or scene's title, content, or position
      description: Full replacement of `content` when provided -- e.g. save generated prose into a chapter. Chapters are stored as plain text with a blank line between paragraphs.
      x-required-scope: stories:write
      parameters:
      - $ref: '#/components/parameters/StoryId'
      - name: chapterId
        in: path
        required: true
        schema:
          type: string
          format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                title:
                  type: string
                content:
                  type: string
                order_index:
                  type: integer
                  minimum: 0
      responses:
        '200':
          description: The updated chapter.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChapterDetail'
        '400':
          $ref: '#/components/responses/InvalidRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
    delete:
      operationId: deleteChapter
      tags:
      - chapters
      summary: Delete a chapter or scene
      description: 'Irreversible. The first call always fails with `confirmation_required`; retry with `confirm: true` to actually delete.'
      x-required-scope: stories:write
      parameters:
      - $ref: '#/components/parameters/StoryId'
      - name: chapterId
        in: path
        required: true
        schema:
          type: string
          format: uuid
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                confirm:
                  type: boolean
      responses:
        '200':
          description: Deleted.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: 'Destructive action needs `confirm: true` to proceed, or the resource changed since you last read it.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          $ref: '#/components/responses/RateLimited'
  /stories/{id}/chapters/{chapterId}/apply-edit:
    post:
      operationId: applyEdit
      tags:
      - chapters
      summary: Replace one exact, unique text span in a chapter
      description: 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.
      x-required-scope: stories:write
      parameters:
      - $ref: '#/components/parameters/StoryId'
      - name: chapterId
        in: path
        required: true
        schema:
          type: string
          format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - old_text
              - new_text
              properties:
                old_text:
                  type: string
                  description: Exact text to replace, copied verbatim from the chapter. Must be unique in the chapter.
                new_text:
                  type: string
      responses:
        '200':
          description: The updated chapter.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChapterDetail'
        '400':
          $ref: '#/components/responses/InvalidRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
  /stories/{id}/manuscript/find-replace:
    post:
      operationId: findReplace
      tags:
      - chapters
      summary: Deterministic find/replace across one chapter or the whole manuscript
      description: No AI rewrite -- a literal text substitution, not a regex. Story-wide replacements snapshot each affected chapter first so they stay undoable.
      x-required-scope: stories:write
      parameters:
      - $ref: '#/components/parameters/StoryId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - find
              - replace
              - scope
              properties:
                find:
                  type: string
                replace:
                  type: string
                scope:
                  type: string
                  enum:
                  - chapter
                  - story
                chapter_id:
                  type: string
                  format: uuid
                  description: Required when scope is "chapter".
                case_sensitive:
                  type: boolean
                  default: false
                whole_word:
                  type: boolean
                  default: false
      responses:
        '200':
          description: Match count and the chapters affected.
          content:
            application/json:
              schema:
                type: object
                properties:
                  replacements:
                    type: integer
                  chapters_affected:
                    type: integer
        '400':
          $ref: '#/components/responses/InvalidRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  schemas:
    ChapterDetail:
      allOf:
      - $ref: '#/components/schemas/ChapterSummary'
      - type: object
        properties:
          content:
            type: string
    ChapterSummary:
      type: object
      properties:
        id:
          type: string
          format: uuid
        title:
          type: string
        type:
          type: string
          enum:
          - chapter
          - scene
        order:
          type: integer
        word_count:
          type: integer
        updated_at:
          type:
          - string
          - 'null'
          format: date-time
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
              - unauthorized
              - forbidden
              - invalid_request
              - not_found
              - rate_limited
              - internal_error
            message:
              type: string
  responses:
    InvalidRequest:
      description: The request body or parameters are invalid.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: The token lacks the scope this endpoint requires.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Missing, malformed, invalid, revoked, or expired token.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    RateLimited:
      description: Too many requests. Retry after the delay in the `Retry-After` header.
      headers:
        Retry-After:
          schema:
            type: integer
          description: Seconds to wait before retrying.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: The resource does not exist or you do not own it.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  parameters:
    StoryId:
      name: id
      in: path
      required: true
      schema:
        type: string
        format: uuid
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: ash_...
      description: 'Create a token under Settings, Developer API and send it as `Authorization: Bearer ash_...`. Each endpoint requires one scope, listed per-operation via the `x-required-scope` extension; see https://aistoryhub.co/developers for the full scope list.'