Skip to main content
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
}

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/praveenarya123/sps-backend/llms.txt

Use this file to discover all available pages before exploring further.

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 the Authorization 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

classId
number
required
Numeric identifier of the class the assignment is for.
title
string
required
Title of the assignment, for example "Chapter 5 Homework" or "Midterm Essay".
dueDate
string
required
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.
_id
string
required
MongoDB-generated unique identifier for the assignment.
classId
number
required
Numeric identifier of the class this assignment belongs to.
title
string
required
Title of the assignment.
dueDate
string
required
Due date of the assignment as an ISO 8601 date-time string.
teacherId
string
required
MongoDB ObjectId of the teacher who created the assignment. Populated from the authenticated user’s JWT.
__v
number
MongoDB internal version key.

Error responses

StatusMessageCause
401UnauthorizedNo Authorization header was provided.
403Access deniedA 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
}

Build docs developers (and LLMs) love