curl --request POST \
--url https://your-api-host/api/teacher/assignment \
--header 'Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...' \
--header 'Content-Type: application/json' \
--data '{
"classId": 301,
"title": "Chapter 5 Homework",
"dueDate": "2026-04-15T23:59:00.000Z"
}'
{
"_id": "64f2c3d4e5f6a7b8c9d0e1f2",
"classId": 301,
"title": "Chapter 5 Homework",
"dueDate": "2026-04-15T23:59:00.000Z",
"teacherId": "64f1a2b3c4d5e6f7a8b9c0d9",
"__v": 0
}
Teachers
Create assignment
Create a new assignment for a class. Requires a valid teacher JWT and TEACHER role.
POST
/
api
/
teacher
/
assignment
curl --request POST \
--url https://your-api-host/api/teacher/assignment \
--header 'Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...' \
--header 'Content-Type: application/json' \
--data '{
"classId": 301,
"title": "Chapter 5 Homework",
"dueDate": "2026-04-15T23:59:00.000Z"
}'
{
"_id": "64f2c3d4e5f6a7b8c9d0e1f2",
"classId": 301,
"title": "Chapter 5 Homework",
"dueDate": "2026-04-15T23:59:00.000Z",
"teacherId": "64f1a2b3c4d5e6f7a8b9c0d9",
"__v": 0
}
Creates a new assignment record and associates it with the authenticated teacher. The
teacherId is extracted automatically from the JWT — it cannot be set manually in the request body.
This endpoint requires the
TEACHER role. Requests from authenticated users with any other role will receive a 403 Access denied response. Ensure your JWT was issued to an account with the TEACHER role before calling this endpoint.Authentication
This endpoint requires a valid JWT passed in theAuthorization header.
Authorization: <your-jwt-token>
teacherId is automatically set from your JWT payload (req.user.id). Do not include teacherId in the request body — it will be ignored.Request body
Numeric identifier of the class the assignment is for.
Title of the assignment, for example
"Chapter 5 Homework" or "Midterm Essay".Due date for the assignment as an ISO 8601 date-time string, for example
"2026-04-15T23:59:00.000Z".Response
Returns the newly created assignment object.MongoDB-generated unique identifier for the assignment.
Numeric identifier of the class this assignment belongs to.
Title of the assignment.
Due date of the assignment as an ISO 8601 date-time string.
MongoDB ObjectId of the teacher who created the assignment. Populated from the authenticated user’s JWT.
MongoDB internal version key.
Error responses
| Status | Message | Cause |
|---|---|---|
401 | Unauthorized | No Authorization header was provided. |
403 | Access denied | A valid token was provided but the user does not have the TEACHER role. |
curl --request POST \
--url https://your-api-host/api/teacher/assignment \
--header 'Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...' \
--header 'Content-Type: application/json' \
--data '{
"classId": 301,
"title": "Chapter 5 Homework",
"dueDate": "2026-04-15T23:59:00.000Z"
}'
{
"_id": "64f2c3d4e5f6a7b8c9d0e1f2",
"classId": 301,
"title": "Chapter 5 Homework",
"dueDate": "2026-04-15T23:59:00.000Z",
"teacherId": "64f1a2b3c4d5e6f7a8b9c0d9",
"__v": 0
}
⌘I