---
title: "Add Unit With Ai"
method: POST
path: "/teacher/courses/{course_id}/units/add"
tags: ["Teacher Course Structure"]
---

# Add Unit With Ai

`POST /teacher/courses/{course_id}/units/add`

Add a new unit to the course using AI generation based on the provided prompt.

The new unit will be inserted at the specified position, or at the end if no position is given.

## Path parameters

- `course_id` string, required

## Request body

- AddUnitRequest — Request model for adding a new unit with AI generation.
  - `prompt` string, required — Instructions for the new unit content
  - `position` integer, nullable — Position to insert the unit (0-based, None for end)
  - `title` string, nullable — Optional title for the new unit

## Response `200`

Successful Response

- CourseStructureResponse — Response model for course structure operations.
  - `status` string, required
  - `message` string, required
  - `course` Course, required — Represents a user course created through image uploads.
    - `_id` string
    - `user_id` string, required
    - `is_teacher_course` boolean
    - `folder_id` string, nullable
    - `title` string, required
    - `subject` string, nullable
    - `status` 'UPLOADING' | 'PROCESSING_IMAGES' | 'STRUCTURING' | 'GENERATING_CONTENT' | 'COMPLETED' | 'FAILED'
    - `original_image_paths` string[]
    - `raw_content_blob` string, nullable
    - `units` CourseUnit[], nullable
      - `unit_id` string
      - `type` 'chapter' | 'section' | 'topic' | 'concept_explanation' | 'introduction' | 'conclusion' | 'content' | 'flashcards' | 'qcm', required — Valid unit types for course content
      - `title` string, required
      - `unit_summary` string, required
      - `suggested_content_type` 'chapter' | 'section' | 'topic' | 'concept_explanation' | 'introduction' | 'conclusion' | 'content' | 'flashcards' | 'qcm' — Valid unit types for course content
      - `brief_description` string, nullable
      - `generated_content` string, nullable
    - `generated_course_content` string, nullable
    - `revision_deck_status` 'GENERATING' | 'COMPLETED' | 'FAILED', nullable
    - `knowledge_quiz_status` 'GENERATING' | 'COMPLETED' | 'FAILED', nullable
    - `error_message` string, nullable
    - `warnings` string[], nullable
    - `figures_crop` object, nullable
    - `processing_options` object, nullable
    - `source_type` 'student_upload' | 'teacher_assigned' | 'holiday_workbook', nullable
    - `holiday_course_context` object, nullable
    - `created_at` string, date-time
    - `updated_at` string, date-time

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.dev/excellence-ai/apis/excellence-learning.md) · [All operations](https://skmtc.dev/excellence-ai/apis/excellence-learning/llms.txt) · [OpenAPI document](https://skmtc.dev/excellence-ai/apis/excellence-learning/revisions/2a0c1636fd3b?raw)
