All Docs
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 published status.

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:

ConditionError
Caller is not authenticatedUnauthorized
Caller is not a member of the organizationForbidden
Course is not publishedBad Request
Learner is already enrolledConflict

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:

ConditionError
Caller is not authenticatedUnauthorized
Caller is not a member of the organizationForbidden
Enrollment record not foundNot 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