---
title: "Replace Exercise In Assignment"
method: POST
path: "/teacher/assignments/{assignment_id}/exercises/{exercise_id}/replace"
tags: ["teacher_assignments"]
---

# Replace Exercise In Assignment

`POST /teacher/assignments/{assignment_id}/exercises/{exercise_id}/replace`

## 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/assignments/{assignment_id}/exercises/{exercise_id}/replace`
- Auth: OAuth 2
  - Password
  - Token URL: `api/login`
- TypeScript: <https://skmtc.dev/excellence-ai/apis/excellence-learning/docs/teacher/assignments/:assignment_id/exercises/:exercise_id/replace/post.ts> (a function with typed inputs; its response is checked against the schema)

Swap one exercise of the devoir for one or more of the teacher's own.

What the chat's « coupe cet exercice en 4 » lands on: the new exercises
take the slot of the original (same position, same order), the original
leaves the devoir with its per-exercise policies, and the students'
sessions get the same splice. The new exercises inherit the settings of
the one they replace (retry count, chat share) so a split does not reset
what the teacher had configured. The ids are teacher exercises the caller
already owns (the chat just created them for this), so unlike
`add_exercises_to_assignment` nothing is copied.

## Path parameters

- `assignment_id` string, required
- `exercise_id` string, required

## Request body

- ReplaceExerciseRequest: The teacher exercises that take the slot of one exercise of the devoir.
  - `exercise_ids` string[], required

## Response `200`

Successful Response

- AutoSaveResponse
  - `status` string
  - `message` string
  - `updated_at` string, date-time, required
  - `exercise_ids` string[], nullable
  - `exercises` AssignmentExerciseStub[], nullable
    - `id` string, required
    - `order` integer, required
    - `source` 'teacher' | 'public' | 'calcul_template' | 'annale' | 'unknown'
    - `title` string, nullable
    - `original_id` string, nullable
    - `source_public_exercise_id` string, nullable
    - `source_annales_exercise_id` string, nullable
    - `estimated_minutes` integer, nullable
    - `estimated_minutes_pending` boolean
  - `added_exercises` AssignmentExerciseStub[], nullable
    - `id` string, required
    - `order` integer, required
    - `source` 'teacher' | 'public' | 'calcul_template' | 'annale' | 'unknown'
    - `title` string, nullable
    - `original_id` string, nullable
    - `source_public_exercise_id` string, nullable
    - `source_annales_exercise_id` string, nullable
    - `estimated_minutes` integer, nullable
    - `estimated_minutes_pending` boolean
  - `removed_exercise_ids` string[], nullable
  - `new_exercise_ids` string[], nullable
  - `imported_exercises` object[], nullable
  - `chat_scoring_policy` object, nullable

## Other responses

- `422`: Validation Error

## Changes

> 86 revisions in range; 1 not diffed.

- **2026-11-07** `de94c586d9fb`: 1 info
  - added the optional property `chat_scoring_policy` to the response with the `200` status
- **2026-09-16** `9f813eb42d6f`: 2 info
  - added the optional property `added_exercises/anyOf[subschema #1]/items/estimated_minutes_pending` to the response with the `200` status
  - added the optional property `exercises/anyOf[subschema #1]/items/estimated_minutes_pending` to the response with the `200` status
- **2026-09-09** `e75413b9576a`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/excellence-ai/apis/excellence-learning/changes/teacher/assignments/:assignment_id/exercises/:exercise_id/replace/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/798883bdd94a?raw)
