All Docs
FeaturesCSI Teachable Replacement AppUpdated March 13, 2026

Blog: Learner Enrollment tRPC API — Controlled, Safe, and Multi-Tenant

Learner Enrollment tRPC API — Controlled, Safe, and Multi-Tenant

Release v1.0.37

With v1.0.37 we are shipping the server-side enrollment layer: the set of tRPC procedures that govern how learners join and leave courses on the platform. This is a foundational piece of the platform's course delivery experience.


What Was Built

Two tRPC mutations now handle the full enrollment lifecycle:

  • enrollment.enroll — Admits a learner to a course.
  • enrollment.unenroll — Removes a learner from a course.

These are not thin CRUD wrappers. Each procedure enforces a layered set of rules before any database write occurs.


The Rules

1. Authentication First

Both procedures require a valid authenticated session. Unauthenticated callers are rejected immediately.

2. Organization Membership Check

Our platform is multi-tenant. A learner can only interact with courses that belong to the organization they are a verified member of. This check is performed server-side on every request, making cross-tenant enrollment impossible regardless of what the client sends.

This is especially important given our SSO-based access model — learners authenticate through their organization's identity provider, and membership is derived from that identity context.

3. Published Courses Only

Enrollment is gated on course status. A learner cannot enroll in a course that hasn't been published yet. This protects authors who are still building out content from accidentally having learners access incomplete material.

4. No Duplicate Enrollments

The enrollment procedure checks whether the learner already holds an active enrollment for the requested course. If they do, the request is rejected cleanly rather than creating a duplicate record. This keeps enrollment data consistent and avoids downstream issues in progress tracking.


Why tRPC

Using tRPC for these procedures means the enrollment API is fully type-safe end-to-end. The client calling enrollment.enroll or enrollment.unenroll gets compile-time guarantees about the shape of the request and response — no manual API contract maintenance required.


What This Enables

With the enrollment API in place, the platform can now:

  • Gate learner access to course content based on enrollment status.
  • Display accurate enrollment counts and learner rosters to course authors.
  • Support self-service enrollment flows in the learner-facing UI.
  • Support administrative unenrollment workflows.

Further Reading