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 Code | Error Code | Description |
|---|---|---|
| 401 | HTTP_401 | Unauthorized |
| 404 | HTTP_404 | Not Found |
| 403 | HTTP_403 | Forbidden |
| 400 | HTTP_400 | Bad Request |
| 400 | HTTP_400 | Bad Request |
| 404 | HTTP_404 | Not Found |
| 403 | HTTP_403 | Forbidden |
| 429 | HTTP_429 | Error |
| 500 | HTTP_500 | Internal Server Error |
| 500 | HTTP_500 | Internal Server Error |
Example Request
curl -X POST "https://api.allurelms.com/modules" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{}'