> ## Documentation Index
> Fetch the complete documentation index at: https://docs.babou.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Chapter

> Add a new chapter to a video project

## Overview

Creates a new chapter within a project. Chapters are segments of your video that can have individual content and duration.

## Request

### Path Parameters

<ParamField path="projectId" type="string" required>
  The project ID
</ParamField>

### Headers

<ParamField header="Authorization" type="string" required>
  Bearer token with your API key
</ParamField>

<ParamField header="Content-Type" type="string" required>
  Must be `application/json`
</ParamField>

### Body

<ParamField body="name" type="string" required>
  Chapter name (1-30 characters)
</ParamField>

<ParamField body="duration" type="number">
  Optional duration in seconds (must be positive integer)
</ParamField>

## Response

<ResponseField name="id" type="string">
  Unique chapter identifier (format: `cht_[A-Za-z0-9]{21}`)
</ResponseField>

<ResponseField name="project_id" type="string">
  Parent project ID
</ResponseField>

<ResponseField name="name" type="string">
  Chapter name
</ResponseField>

<ResponseField name="duration" type="number">
  Duration in seconds
</ResponseField>

<ResponseField name="created_at" type="string">
  ISO 8601 timestamp when the chapter was created
</ResponseField>

## Examples

<CodeGroup>
  ```bash curl theme={null}
  curl -X POST https://api.babou.ai/api/v1/projects/prj_abc123xyz/chapters \
    -H "Authorization: Bearer $BABOU_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Introduction",
      "duration": 30
    }'
  ```

  ```typescript TypeScript theme={null}
  async function createChapter(
    projectId: string,
    name: string,
    duration?: number
  ) {
    const response = await fetch(
      `https://api.babou.ai/api/v1/projects/${projectId}/chapters`,
      {
        method: 'POST',
        headers: {
          'Authorization': `Bearer ${process.env.BABOU_API_KEY}`,
          'Content-Type': 'application/json'
        },
        body: JSON.stringify({ name, duration })
      }
    );

    return await response.json();
  }

  const chapter = await createChapter('prj_abc123xyz', 'Introduction', 30);
  console.log('Created chapter:', chapter.id);
  ```

  ```python Python theme={null}
  import os
  import requests

  def create_chapter(project_id, name, duration=None):
      response = requests.post(
          f'https://api.babou.ai/api/v1/projects/{project_id}/chapters',
          headers={
              'Authorization': f'Bearer {os.environ["BABOU_API_KEY"]}',
              'Content-Type': 'application/json'
          },
          json={'name': name, 'duration': duration}
      )
      return response.json()

  chapter = create_chapter('prj_abc123xyz', 'Introduction', 30)
  print(f'Created chapter: {chapter["id"]}')
  ```
</CodeGroup>

## Response Example

```json theme={null}
{
  "id": "cht_def456uvw",
  "project_id": "prj_abc123xyz",
  "name": "Introduction",
  "duration": 30,
  "created_at": "2025-12-02T10:01:00Z"
}
```

## Error Responses

<ResponseField name="VALIDATION_ERROR" type="400">
  Invalid request parameters

  ```json theme={null}
  {
    "error": "Validation failed",
    "code": "VALIDATION_ERROR",
    "hint": "Name must be between 1 and 30 characters"
  }
  ```
</ResponseField>

<ResponseField name="NOT_FOUND" type="404">
  Project not found

  ```json theme={null}
  {
    "error": "Project not found",
    "code": "NOT_FOUND"
  }
  ```
</ResponseField>

## Next Steps

<CardGroup cols={2}>
  <Card title="Submit Prompt" icon="wand-magic-sparkles" href="/api-reference/prompts/submit">
    Add video content to this chapter
  </Card>

  <Card title="List Chapters" icon="list" href="/api-reference/chapters/list">
    View all chapters in the project
  </Card>
</CardGroup>
