> ## Documentation Index
> Fetch the complete documentation index at: https://www.studyfetch.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Grade a new assignment

> Submits student work to the AI grader. You must provide exactly one of materialId or textToGrade, and at least one of rubric or rubricTemplateId.



## OpenAPI

````yaml /openapi-components.json post /api/v1/assignment-grader/create
openapi: 3.0.0
info:
  title: StudyFetch API
  description: API documentation for StudyFetch
  version: '1.0'
  contact: {}
servers:
  - url: https://studyfetchapi.com
    description: Production API Server
security: []
tags: []
paths:
  /api/v1/assignment-grader/create:
    post:
      tags:
        - Assignment Grader
      summary: Grade a new assignment
      description: >-
        Submits student work to the AI grader. You must provide exactly one of
        materialId or textToGrade, and at least one of rubric or
        rubricTemplateId.
      operationId: createAssignmentGrader
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateAssignmentGraderDto'
      responses:
        '201':
          description: Assignment grading completed
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  gradedAssignment:
                    $ref: '#/components/schemas/AssignmentGraderResponseDto'
        '400':
          description: >-
            Invalid request — missing required fields, both materialId and
            textToGrade supplied, neither rubric nor template provided, or empty
            rubric
        '401':
          description: Missing or invalid authentication
        '404':
          description: Referenced rubricTemplateId or materialId not found
      security:
        - x-api-key: []
        - bearerAuth: []
components:
  schemas:
    CreateAssignmentGraderDto:
      type: object
      properties:
        title:
          type: string
          description: Title of the assignment
        materialId:
          type: string
          description: Material ID to grade
        textToGrade:
          type: string
          description: Text content to grade
        userId:
          type: string
          description: User ID for tracking
        model:
          type: string
          description: AI model to use
        rubric:
          description: Grading rubric
          allOf:
            - $ref: '#/components/schemas/RubricDto'
        rubricTemplateId:
          type: string
          description: Rubric template ID to use
        assignmentId:
          type: string
          description: Assignment ID for grouping submissions
        studentIdentifier:
          type: string
          description: Student identifier (email or ID)
        assignmentContent:
          type: string
          description: >-
            Source material / passage / instructions students were given. The AI
            grader uses this as the authoritative reference when evaluating the
            student's submission.
      required:
        - title
    AssignmentGraderResponseDto:
      type: object
      properties:
        _id:
          type: string
          description: Assignment grader ID
        title:
          type: string
          description: Assignment title
        grade:
          type: number
          description: Overall percentage (0-100), rounded to nearest whole number
        rubric:
          description: Grading results with per-criterion scores and feedback
          allOf:
            - $ref: '#/components/schemas/GradedRubricDto'
        organizationId:
          type: string
          description: Owning organization ID
        userId:
          type: string
          nullable: true
          description: User who triggered the grading (null for API-key auth)
        materialId:
          type: string
          description: Material that was graded (mutually exclusive with textToGrade)
        textToGrade:
          type: string
          description: Raw text that was graded
        rubricTemplateId:
          type: string
          description: Rubric template used (if any)
        assignmentId:
          type: string
          description: Grouping tag for educator reports
        studentIdentifier:
          type: string
          description: Student email or ID
        assignmentContent:
          type: string
          description: Source material the AI used as the authoritative reference
        createdAt:
          format: date-time
          type: string
          description: Creation timestamp
        updatedAt:
          format: date-time
          type: string
          description: Update timestamp
        __v:
          type: number
          description: Mongoose version key
      required:
        - _id
        - title
        - grade
        - rubric
        - organizationId
        - createdAt
        - updatedAt
        - __v
    RubricDto:
      type: object
      properties:
        criteria:
          description: Grading criteria
          type: array
          items:
            $ref: '#/components/schemas/RubricCriterionDto'
        assignmentContent:
          type: string
          description: >-
            Optional source material. Superseded by top-level assignmentContent
            if both are provided.
      required:
        - criteria
    GradedRubricDto:
      type: object
      properties:
        attemptFeedback:
          type: string
          description: Holistic feedback for the entire submission
        criteria:
          type: array
          description: Per-criterion grading results
          items:
            $ref: '#/components/schemas/GradedRubricCriterionDto'
      required:
        - attemptFeedback
        - criteria
    RubricCriterionDto:
      type: object
      properties:
        title:
          type: string
          description: Title of the criterion
        description:
          type: string
          description: Description of the criterion
        pointsPossible:
          type: number
          description: Points possible for this criterion
      required:
        - title
        - pointsPossible
    GradedRubricCriterionDto:
      type: object
      properties:
        title:
          type: string
          description: Criterion title (mirrors the input)
        description:
          type: string
          description: Criterion description (mirrors the input)
        pointsAwarded:
          type: number
          description: Points the AI awarded for this criterion
        pointsPossible:
          type: number
          description: Maximum points for this criterion
        feedback:
          type: string
          description: Per-criterion feedback addressed to the student
      required:
        - title
        - pointsAwarded
        - pointsPossible
        - feedback
  securitySchemes:
    x-api-key:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        API Key for server-to-server authentication. Resolves to the owning
        organization.
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        JWT bearer token for user session authentication. Resolves to both
        organization and user.

````