# COURSES

courses endpoints.

**Base URL:** `https://api.trustpager.com/functions/v1/api/v1`

## Endpoints

### POST /courses

Create a training course. Requires a title; new courses start as draft.

**Scopes:** `courses:write` — [full detail](./courses/post-courses.md)

### POST /courses/:course_id/modules

Add a module to a training course. Requires a title.

**Scopes:** `courses:write` — [full detail](./courses/post-courses-course-id-modules.md)

### POST /courses/:course_id/modules/:module_id/questions

Add a choice question to a course module quiz. Needs prompt, options (2 or more) and correct_index (the one correct option, 0-based). Free-text and multi-answer questions are refused.

**Scopes:** `courses:write` — [full detail](./courses/post-courses-course-id-modules-module-id-questions.md)

### DELETE /courses/:course_id

Delete a training course by UUID. Refused (409) while the course has entitlements or quiz attempts: archive it instead.

**Scopes:** `courses:delete` — [full detail](./courses/delete-courses-course-id.md)

### DELETE /courses/:course_id/modules/:module_id

Delete a course module by UUID. Refused (409) while learners have progress or quiz attempts on it.

**Scopes:** `courses:delete` — [full detail](./courses/delete-courses-course-id-modules-module-id.md)

### DELETE /courses/:course_id/modules/:module_id/questions/:question_id

Remove a question from a course module quiz. The question is hidden, not erased, so learner attempt history that used it stays intact.

**Scopes:** `courses:write` — [full detail](./courses/delete-courses-course-id-modules-module-id-questions-question-id.md)

### GET /courses/library

List the training courses one contact owns (active access only; pass include_ended=true to include ended access). Needs contact_id.

**Scopes:** `courses:read` — [full detail](./courses/get-courses-library.md)

### GET /courses/:course_id

Fetch a single training course by UUID.

**Scopes:** `courses:read` — [full detail](./courses/get-courses-course-id.md)

### GET /courses/:course_id/modules/:module_id/quiz

Get the quiz settings for one course module (pass_mark, draw_count, max_attempts, cooldown_minutes) and how many questions its bank holds. Returns defaults with configured=false when no quiz is set yet.

**Scopes:** `courses:read` — [full detail](./courses/get-courses-course-id-modules-module-id-quiz.md)

### POST /courses/:course_id/entitlements

Give one contact access to a training course by hand (a manual grant, recorded in the audit trail). Returns the existing grant if the contact already has active access.

**Scopes:** `courses:write` — [full detail](./courses/post-courses-course-id-entitlements.md)

### GET /courses/:course_id/entitlements

List who holds access to a training course (one row per purchase). Pass active=true to hide revoked grants.

**Scopes:** `courses:read` — [full detail](./courses/get-courses-course-id-entitlements.md)

### GET /courses/:course_id/modules

List the modules of a training course, in position order. Paginated.

**Scopes:** `courses:read` — [full detail](./courses/get-courses-course-id-modules.md)

### GET /courses/:course_id/progress

List per-learner, per-module progress for a training course (video watched percent, PDF opened). Filter by contact_id for one learner.

**Scopes:** `courses:read` — [full detail](./courses/get-courses-course-id-progress.md)

### GET /courses/:course_id/modules/:module_id/questions

List the choice questions for one course module, with the correct answer (staff only). Deleted questions are not listed.

**Scopes:** `courses:read` — [full detail](./courses/get-courses-course-id-modules-module-id-questions.md)

### GET /courses

List training courses in the workspace. Filter by status (draft, published, archived).

**Scopes:** `courses:read` — [full detail](./courses/get-courses.md)

### POST /courses/:course_id/entitlements/:entitlement_id/revoke

End one learner access to a training course (soft end, recorded in the audit trail). The grant row and the learner progress are kept. Repeating it is harmless.

**Scopes:** `courses:write` — [full detail](./courses/post-courses-course-id-entitlements-entitlement-id-revoke.md)

### PUT /courses/:course_id/modules/:module_id/quiz

Create or update the quiz settings for one course module. Send only the fields to set; the first call creates the quiz with defaults for the rest.

**Scopes:** `courses:write` — [full detail](./courses/put-courses-course-id-modules-module-id-quiz.md)

### PATCH /courses/:course_id

Update a training course. Pass only the fields you want to change. Set status to published to make it sellable.

**Scopes:** `courses:write` — [full detail](./courses/patch-courses-course-id.md)

### PATCH /courses/:course_id/modules/:module_id

Update a course module. Pass only the fields you want to change.

**Scopes:** `courses:write` — [full detail](./courses/patch-courses-course-id-modules-module-id.md)

### PATCH /courses/:course_id/modules/:module_id/questions/:question_id

Change a choice question. Pass only the fields to change; the result must still have 2 or more options and one correct_index inside them.

**Scopes:** `courses:write` — [full detail](./courses/patch-courses-course-id-modules-module-id-questions-question-id.md)
