> ## 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.

# Submit assignment

> Submit a student assignment with a file URL and timestamp.

Creates a new assignment submission record. Pass the assignment and student identifiers, a URL pointing to the submitted file, and the submission timestamp.

<Note>
  This endpoint requires no authentication.
</Note>

## Request

### Body parameters

<ParamField body="assignmentId" type="string" required>
  The MongoDB ObjectId of the assignment being submitted. Must be a valid 24-character hex string.
</ParamField>

<ParamField body="studentId" type="string" required>
  The MongoDB ObjectId of the student submitting the assignment. Must be a valid 24-character hex string.
</ParamField>

<ParamField body="fileUrl" type="string" required>
  A URL pointing to the submitted file (e.g., a cloud storage URL). The file must be accessible at this URL at the time of grading.
</ParamField>

<ParamField body="submittedAt" type="string" required>
  The submission timestamp in ISO 8601 format (e.g., `2026-03-18T14:30:00.000Z`).
</ParamField>

<Tip>
  Set `submittedAt` to the current timestamp by using `new Date().toISOString()` in JavaScript or `datetime.utcnow().isoformat()` in Python. This ensures the recorded time accurately reflects when the submission was made.
</Tip>

## Response

Returns the created submission document.

<ResponseField name="_id" type="string">
  The MongoDB ObjectId of the newly created submission record.
</ResponseField>

<ResponseField name="assignmentId" type="string">
  The MongoDB ObjectId of the assignment.
</ResponseField>

<ResponseField name="studentId" type="string">
  The MongoDB ObjectId of the student.
</ResponseField>

<ResponseField name="fileUrl" type="string">
  The URL of the submitted file.
</ResponseField>

<ResponseField name="submittedAt" type="string">
  The submission timestamp in ISO 8601 format.
</ResponseField>

<ResponseField name="__v" type="number">
  Mongoose internal version key.
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url http://localhost:5000/api/assignment/submit \
    --header 'Content-Type: application/json' \
    --data '{
      "assignmentId": "64b8f1a2c3d4e5f678905678",
      "studentId": "64b8f1a2c3d4e5f678901234",
      "fileUrl": "https://storage.example.com/submissions/essay-final.pdf",
      "submittedAt": "2026-03-18T14:30:00.000Z"
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "_id": "64d0b4c8e3f2a1b096785432",
    "assignmentId": "64b8f1a2c3d4e5f678905678",
    "studentId": "64b8f1a2c3d4e5f678901234",
    "fileUrl": "https://storage.example.com/submissions/essay-final.pdf",
    "submittedAt": "2026-03-18T14:30:00.000Z",
    "__v": 0
  }
  ```
</ResponseExample>
