---
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`

## Request

- Base URL: `https://api.excellence-ai.com` (the document declares no server; this is the origin it was published from)
- URL: `https://api.excellence-ai.com/teacher/courses/{course_id}/units/add`
- Auth: OAuth 2 (password, token URL `api/login`)

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
      - `blocks` CourseBlock[], nullable
        - `id` string, required
        - `type` 'paragraph' | 'theorem' | 'definition' | 'example' | 'property' | 'explanation' | 'note' | 'demonstration' | 'illustration' | 'video' | 'interactive', required
        - `content` string, required
    - `generated_course_content` string, nullable
    - `revision_deck_status` 'GENERATING' | 'COMPLETED' | 'FAILED', nullable
    - `knowledge_quiz_status` 'GENERATING' | 'COMPLETED' | 'FAILED', nullable
    - `append_status` 'GENERATING' | 'COMPLETED' | 'FAILED', nullable
    - `append_started_at` string, date-time, nullable
    - `append_error_message` string, nullable
    - `error_message` string, nullable
    - `warnings` string[], nullable
    - `figures_crop` object, nullable
    - `processing_options` object, nullable
    - `source_type` 'student_upload' | 'teacher_assigned' | 'holiday_workbook' | 'excellence_course', nullable
    - `excellence_course_key` string, nullable
    - `excellence_content_signature` string, nullable
    - `excellence_unmodified` boolean, nullable
    - `holiday_course_context` object, nullable
    - `created_at` string, date-time
    - `updated_at` string, date-time

## Other responses

- `422`: Validation Error

## Changes

> 55 revisions in range; 1 not diffed.

- **2026-10-15** `7925dd21e4d0`: 3 warning, 6 info
  - added the new `excellence_course` enum value to the `course/source_type/anyOf[subschema #1]/` response property for the response status `200`
  - added the new `interactive` enum value to the `course/units/anyOf[subschema #1]/items/blocks/anyOf[subschema #1]/items/type` response property for the response status `200`
  - added the new `video` enum value to the `course/units/anyOf[subschema #1]/items/blocks/anyOf[subschema #1]/items/type` response property for the response status `200`
  - added the optional property `course/append_error_message` to the response with the `200` status
  - …5 more
- **2026-09-19** `c81ed506912f`: 1 info
  - added the optional property `course/units/anyOf[subschema #1]/items/blocks` to the response with the `200` status

[Operation history](https://skmtc.dev/excellence-ai/apis/excellence-learning/changes/teacher/courses/:course_id/units/add/post.md)

---

[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/379e4a57dee8?raw)
