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

ParameterTypeDescription
pagestringQuery parameter
limitstringQuery parameter
searchstringQuery parameter
statusstringQuery parameter
instructorIdstringQuery parameter

Error Responses

Status CodeError CodeDescription
401HTTP_401Unauthorized
404HTTP_404Not Found
500HTTP_500Internal Server Error
500HTTP_500Internal Server Error
401HTTP_401Unauthorized
404HTTP_404Not Found
403HTTP_403Forbidden
429HTTP_429Error
400HTTP_400Bad Request
400HTTP_400Bad Request
400HTTP_400Bad Request
404HTTP_404Not Found
500HTTP_500Internal Server Error
500HTTP_500Internal Server Error

Example Request

curl -X POST "https://api.allurelms.com/courses" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}'