Skip to main content
Manage the lessons inside a chapter: list, create, reorder, show, update, permanently delete, and toggle a student’s completion status. All endpoints are authenticated — they run behind auth:sanctum, the “user is not blocked” check, and the per-company policy middleware. Always send your Sanctum token as a Bearer header.

Table of contents

  • Base URL & Headers
  • List lessons
  • Reorder lessons
  • Create a lesson
  • Retrieve a lesson
  • Update a lesson
  • Permanently delete a lesson
  • Toggle lesson validation for a student
  • Postman setup

Base URL & Headers

Dates are returned in Y-m-d H:i:s format. Boolean query params accept true, false, 1, 0.
A lesson’s position is assigned automatically on creation (next available slot per chapter). You only send position when you want to change it via update or reorder.

List lessons

GET /lessons Returns a paginated list of lessons belonging to a given chapter, ordered by position.

Query parameters

Example request

Response — 200 OK


Reorder lessons

POST /lessons/reorder Bulk-updates the position of multiple lessons in a single call. The request body is a bare array — not an object.

Body

An array of { id, position } pairs.

Example request

Response — 200 OK


Create a lesson

POST /lesson Creates a lesson inside a chapter. The position is assigned automatically (one higher than the current maximum for that chapter).

Body parameters

Example request

Responses

200 OK
422 Unprocessable Entity — unknown type

Retrieve a lesson

GET /lesson/{id} Returns a single lesson.

Example request

Response — 200 OK

404 Not Found


Update a lesson

POST /lesson/{id} Updates an existing lesson. Unlike create, position is required here — send the current position if you don’t want to move the lesson.

Body parameters

Example request

Response — 200 OK


Permanently delete a lesson

DELETE /lesson/{id}/hard_delete Force-deletes the lesson. The operation is irreversible.
⚠️ This hard-deletes the record — it does not soft-delete. If you need to keep history, archive upstream (e.g. the chapter or training) instead.

Example request

Response — 200 OK


Toggle lesson validation for a student

POST /lesson/{id}/toggle_lesson_validation Marks (or un-marks) a lesson as completed for a specific student. This attaches or detaches the student from the lesson in the student_lesson pivot table. The response includes the fresh user progress computed by the Dashboard service, so the client can refresh its progress UI in the same round-trip.

Body parameters

Example request — mark as completed

Example request — un-mark (remove completion)

Response — 200 OK

The exact shape of user_progress matches whatever DashboardsController@userProgress returns for that user. Treat the example above as illustrative, not authoritative.

Error responses

422 Unprocessable Entity — missing or invalid fields:

Postman setup

  1. Environment variables.
    • base_url — your API root, e.g. http://localhost:8000
    • token — the Sanctum token returned by POST /auth/login
  2. Collection-level headers.
    • Accept: application/json
    • Authorization: Bearer {{token}}
  3. Request bodies.
    • JSON bodies → Body → raw → JSON
    • For Reorder, the body is a bare JSON array, not an object wrapped in a key.
    • content must always be present on create and update — use an empty string ("") rather than omitting it if the lesson has no body text.
    • type is optional (document by default). It is set by hand in the training editor: the backend never derives it from the HTML, and every lesson created before 16/10/2026 is document until an author switches it to video.
  4. Smoke-test flow.
    1. POST /lesson — create
    2. GET /lessons?chapter_id={id} — verify it appears
    3. POST /lesson/{id} — update
    4. POST /lessons/reorder — reorder with peers
    5. POST /lesson/{id}/toggle_lesson_validation with true — mark as completed
    6. POST /lesson/{id}/toggle_lesson_validation with false — un-mark
    7. DELETE /lesson/{id}/hard_delete — cleanup