POST /courses
POST /courses
GET /api/courses - List courses Check authentication with Clerk Get user's profile to determine role and tenant Parse query parameters Check if fetching own courses (instructorId=me) - needed early for filtering logic Build query based on role Check if user has course creation/building permissions Check for explicit permissions Apply role-based filtering (skip if fetching own courses) Learners without course permissions only see published courses Instructors and users with course permissions see published courses OR their own courses Admins see all courses (no additional filter needed) Apply search filter Apply instructor filter (must come before status filter for 'me' case) Special case: return ALL courses created by the current user (including drafts) When fetching own courses, don't apply status filter unless explicitly requested This allows users to see all their courses regardless of status Apply status filter (only if not fetching own courses or if explicitly requested) Apply pagination and ordering POST /api/courses - Create a new course Check authentication with Clerk Get user's profile to check role and tenant Check if user can create courses (admin or has permission) Check for explicit permission Allow if admin or has explicit permission Apply rate limiting for API mutations Parse request body Validate required fields Validate status Determine instructor ID: - If provided, use it - If admin/super_admin and not provided, default to themselves - If instructor and not provided, default to themselves - If user has course:create permission and not provided, default to themselves Admins can create courses and default to themselves as instructor Instructors default to themselves Users with course:create permission can create courses and default to themselves as instructor Verify instructor exists and belongs to the same tenant Create the course Auto-enroll the creator (instructor) with highest permissions (active status) This ensures instructors/admins can access their own courses immediately Log the error but don't fail course creation Enrollment might already exist or there might be a constraint issue Don't return error - course was created successfully Add rate limit headers
Endpoint
POST /courses
Authentication
This endpoint requires authentication. Include your authentication token in the request headers.
Query Parameters
| Parameter | Type | Description |
|---|---|---|
page | string | Query parameter |
limit | string | Query parameter |
search | string | Query parameter |
status | string | Query parameter |
instructorId | string | Query parameter |
Error Responses
| Status Code | Error Code | Description |
|---|---|---|
| 401 | HTTP_401 | Unauthorized |
| 404 | HTTP_404 | Not Found |
| 500 | HTTP_500 | Internal Server Error |
| 500 | HTTP_500 | Internal Server Error |
| 401 | HTTP_401 | Unauthorized |
| 404 | HTTP_404 | Not Found |
| 403 | HTTP_403 | Forbidden |
| 429 | HTTP_429 | Error |
| 400 | HTTP_400 | Bad Request |
| 400 | HTTP_400 | Bad Request |
| 400 | HTTP_400 | Bad Request |
| 404 | HTTP_404 | Not Found |
| 500 | HTTP_500 | Internal Server Error |
| 500 | HTTP_500 | Internal Server Error |
Example Request
curl -X POST "https://api.allurelms.com/courses" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{}'