POST /modules

POST /modules

POST /api/modules - Create a new module Use service role client to bypass RLS for profile lookup Check authentication with Clerk Get user's profile Check if user has permission to create modules Admins and instructors can create modules, or users with course:build permission Check for explicit permissions if not admin/instructor Parse request body Validate required fields Verify course exists and user has access Check permissions - user can edit if they're the instructor or have course permissions User can create modules if: 1. They're an admin 2. They're the course instructor 3. They have course:build permission (already checked above) Apply rate limiting for API mutations Get max order_index for this course Create module Add rate limit headers

Endpoint

POST /modules

Authentication

This endpoint requires authentication. Include your authentication token in the request headers.

Error Responses

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

Example Request

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