Lesson CRUD API: Create, Update, Reorder & Delete
Lesson CRUD API: Create, Update, Reorder & Delete
Released in v1.0.13
Version 1.0.13 ships a complete lesson management API built on tRPC. Lessons are the atomic content unit that learners consume — each lesson lives inside a section and carries a rich content body, an optional video URL, and an explicit position within its section.
This release gives course builders full programmatic control over the lesson lifecycle: creating new lessons, editing their content, reordering them within a section, and soft-deleting them when they are no longer needed.
What Is a Lesson?
A lesson is the smallest discrete unit of course content. It belongs to a section, which in turn belongs to a course. Each lesson can contain:
- A rich text body — formatted written content (explanations, instructions, transcripts, etc.).
- A video URL — a link to an embedded or hosted video that serves as the primary or supplementary content medium.
- A position — an integer that determines the lesson's order within its parent section.
API Procedures
All lesson operations are exposed as tRPC procedures.
Create a Lesson
Adds a new lesson to a specified section.
Key inputs:
sectionId— the parent section this lesson belongs to.title— the lesson title shown to learners.body— the rich content body (structured text/HTML).videoUrl(optional) — a URL for the lesson's associated video.position— the lesson's order within the section.
Update a Lesson
Edits the metadata or content of an existing lesson.
Key inputs:
lessonId— the lesson to update.title(optional) — updated lesson title.body(optional) — updated rich content body.videoUrl(optional) — updated or replaced video URL.
Reorder Lessons
Adjusts the positional ordering of lessons within a section. Reordering is a first-class operation: each lesson holds an explicit position value, and this procedure updates those values to reflect the new sequence.
Key inputs:
sectionId— the section whose lessons are being reordered.orderedLessonIds— an array of lesson IDs in the desired order.
Delete a Lesson (Soft Delete)
Soft-deletes a lesson, removing it from the learner-facing experience while preserving the underlying record. This supports data recovery and audit trails without permanent data loss.
Key inputs:
lessonId— the lesson to soft-delete.
Soft-deleted lessons are excluded from all learner-facing queries but remain accessible for administrative recovery.
Design Notes
| Concern | Approach |
|---|---|
| Content storage | Rich body field per lesson supports formatted text |
| Video delivery | Video URL is stored as a plain URL field; rendering is handled client-side |
| Ordering | Explicit position integer; reorder procedure updates positions atomically |
| Deletion | Soft delete (flag-based); no hard deletes at this layer |