API ReferenceCSI Teachable Replacement AppUpdated March 13, 2026
Learner Enrollment tRPC API
Learner Enrollment tRPC API
The enrollment API exposes two server-side tRPC procedures for managing learner enrollments within a course. Both procedures are protected and require an authenticated session.
Procedures
enrollment.enroll
Enrolls an authenticated learner in a published course belonging to their organization.
Type: Mutation
Access control:
- The caller must be an authenticated user.
- The caller must be a member of the organization that owns the course.
- The target course must have a
publishedstatus.
Behavior:
- Checks for an existing enrollment record for the learner/course pair.
- If a duplicate is detected, the procedure rejects the request — no duplicate enrollment records are created.
- On success, creates and returns a new enrollment record.
Errors:
| Condition | Error |
|---|---|
| Caller is not authenticated | Unauthorized |
| Caller is not a member of the organization | Forbidden |
| Course is not published | Bad Request |
| Learner is already enrolled | Conflict |
enrollment.unenroll
Withdraws an authenticated learner from a course they are currently enrolled in.
Type: Mutation
Access control:
- The caller must be an authenticated user.
- The caller must be a member of the organization that owns the course.
Behavior:
- Locates the existing enrollment record for the learner/course pair.
- Deletes the enrollment record, effectively unenrolling the learner.
- Does not affect course content, progress history handling is determined by platform configuration.
Errors:
| Condition | Error |
|---|---|
| Caller is not authenticated | Unauthorized |
| Caller is not a member of the organization | Forbidden |
| Enrollment record not found | Not Found |
Security Model
All enrollment procedures enforce multi-tenant isolation at the procedure level. A learner can only enroll in or withdraw from courses that belong to the organization they are a verified member of. This check happens server-side on every request regardless of client input.
Related
- Course Management — Publishing and managing courses
- SSO & Organization Membership — How learner membership is established