The Assignment Grader API allows you to submit student work (text or uploaded materials), define grading criteria via a rubric, and receive AI-generated scores and feedback for every criterion. It supports inline rubrics, reusable rubric templates, assignment content for source-based grading, and aggregate educator reports.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.
Key Features
- Custom Rubrics: Define grading criteria with specific point values
- Flexible Input: Grade from uploaded materials or direct text
- Consistent Grading: AI ensures uniform application of rubric criteria
- Objective Grading: Get numerical grades based on your rubric
- Assignment Content: Provide source material (reading passages, case studies, prompts) that the AI uses as the authoritative reference when grading
- User Tracking: Optional user ID for tracking grading history
- Assignment Groups: Group submissions by assignment ID
- Student Identification: Track submissions by student email or ID
- Rubric Templates: Save and reuse common rubrics
Base URL
All endpoints are relative to your API prefix (defaults toapi/v1):
Authentication
Every endpoint is protected byFlexibleAuthGuard, which accepts either:
| Method | Header | Notes |
|---|---|---|
| API key | x-api-key: <YOUR_API_KEY> | Server-to-server. Resolves to the owning organization. |
| JWT | Authorization: Bearer <JWT> | User session. Resolves to both organization and user. |
401 Unauthorized.
Every record (graded assignment, rubric template) is scoped to the authenticated
organizationId. You can only read/delete records that belong to your org.Common Headers
| Header | Required | Value |
|---|---|---|
Content-Type | On POST requests | application/json |
x-api-key | Yes (or Authorization) | Your API key |
Authorization | Yes (or x-api-key) | Bearer <jwt> |
Endpoint Summary
| # | Method | Path | Purpose |
|---|---|---|---|
| 1 | POST | /assignment-grader/create | Grade a new assignment |
| 2 | GET | /assignment-grader/get | List all graded assignments for the org |
| 3 | GET | /assignment-grader/get/:id | Fetch one graded assignment by ID |
| 4 | DELETE | /assignment-grader/delete/:id | Delete a graded assignment |
| 5 | POST | /assignment-grader/rubric-templates | Create a rubric template |
| 6 | GET | /assignment-grader/rubric-templates | List all rubric templates |
| 7 | GET | /assignment-grader/rubric-templates/:id | Fetch one rubric template |
| 8 | DELETE | /assignment-grader/rubric-templates/:id | Delete a rubric template |
| 9 | GET | /assignment-grader/educator-report/:assignmentId | Aggregate report across all submissions for an assignmentId |
Creating a Rubric Definition
Before grading assignments, you need to define a rubric with specific criteria. Each criterion has:- pointsPossible: The maximum points for this criterion (required)
- title: The name of the criterion (required)
- description: Detailed explanation of what’s being evaluated (optional but recommended)
Create Assignment Grader
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
title | string | Yes | Title of the assignment. |
materialId | string | Conditional* | ID of an uploaded material (PDF, doc, EPUB, etc.) to grade. |
textToGrade | string | Conditional* | Raw text content to grade. |
rubric | Rubric | Conditional** | Inline rubric. |
rubricTemplateId | string | Conditional** | ID of a saved rubric template to use. |
assignmentContent | string | No | Source material / passage / instructions students were given. The AI uses this as the authoritative reference. See Assignment Content. |
assignmentId | string | No | Tag to group multiple submissions under one logical assignment (used by educator reports). |
studentIdentifier | string | No | Student email or ID. |
userId | string | No | User ID for usage tracking (defaults to authenticated user, or anonymous). |
model | string | No | AI model key (defaults to gpt-4o-mini-2024-07-18). |
* You must provide exactly one ofmaterialIdortextToGrade. Providing both or neither returns400 Bad Request. ** You must provide at least one ofrubricorrubricTemplateId. An inlinerubricmust contain at least one criterion.
Example Request (curl)
Response — 201 Created
SDK Examples
Get All Assignment Graders
Example Request (curl)
Response — 200 OK
An array of AssignmentGrader objects.
SDK Examples
Get Assignment Grader by ID
| Path param | Description |
|---|---|
id | Assignment grader document ID (_id). |
Example Request (curl)
Response — 200 OK
A single AssignmentGrader object. Returns 404 Not Found if no assignment matches the ID.
SDK Examples
Delete Assignment Grader
| Path param | Description |
|---|---|
id | Assignment grader document ID. |
Example Request (curl)
Response — 200 OK
404 Not Found if the assignment doesn’t exist or belongs to a different org.
SDK Examples
Generate Educator Report
assignmentId. Use this after grading multiple students for the same logical assignment.
| Path param | Description |
|---|---|
assignmentId | The assignmentId you tagged on each submission when calling POST /create. |
Example Request (curl)
Response — 200 OK
Field Semantics
| Field | Meaning |
|---|---|
statistics.averageGrade | Mean of grade across all matching submissions, formatted to 1 decimal. |
statistics.standardDeviation | Population stddev of grade, 1 decimal. |
gradeDistribution | Letter-grade buckets — A: 90–100, B: 80–89, C: 70–79, D: 60–69, F: below 60. |
criteriaAnalysis | Per-criterion average score across all submissions. |
strengths | Criteria where avgScore / maxPossible >= 0.80. |
weaknesses | Criteria where avgScore / maxPossible < 0.70. |
submissions | Flat list of every submission feeding the report. |
404 Not Found if no submissions match the assignmentId in your organization.
SDK Examples
Rubric Templates
Rubric templates are reusable rubrics scoped to your organization. They optionally store anassignmentContent so the same source material is automatically supplied every time the template is used.
Create Rubric Template
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Display name for the template. |
description | string | No | Notes about when/how to use the template. |
assignmentContent | string | No | Default source material applied to any grading request that uses this template (overridable per request). |
criteria | RubricCriterion[] | Yes | Grading criteria. Must contain at least one entry. |
Example Request (curl)
Response — 201 Created
A RubricTemplate document.
SDK Examples
List Rubric Templates
Example Request (curl)
SDK Examples
Get Rubric Template by ID
| Path param | Description |
|---|---|
id | Rubric template _id. |
RubricTemplate. Returns 404 Not Found if not found in your organization.
SDK Examples
Delete Rubric Template
Response — 200 OK
404 Not Found if the template doesn’t exist or belongs to a different org.
SDK Examples
Assignment Content
TheassignmentContent field provides the AI grader with the original material students were working from — such as a reading passage, case study, or prompt. This is critical for accurate grading because the AI can verify student answers against the actual source instead of relying on its own knowledge.
Where You Can Set It
| Location | When it’s used |
|---|---|
Top-level field on POST /assignment-grader/create | Used for that single grading request |
Inside the rubric object on POST /assignment-grader/create | Same as above (top-level takes priority if both set) |
On a rubric template (POST /assignment-grader/rubric-templates) | Automatically used whenever that template is selected for grading, unless overridden at the request level |
Priority Order
WhenassignmentContent is specified in multiple places, the following priority applies:
- Top-level
assignmentContenton the grading request (highest priority) assignmentContentinside therubricobject on the grading requestassignmentContentsaved on the rubric template (ifrubricTemplateIdis used — lowest priority)
This means you can save a default passage on a rubric template and override it per-request when needed — for example, if you update a passage slightly for one section of students.
Usage Patterns
Every grading request has up to four pieces working together:| Piece | What it is | Where it goes |
|---|---|---|
| Source material | The essay, passage, case study, or prompt the student reads first | assignmentContent |
| Question | What the student is asked to do or answer | Criterion title and description |
| Rubric | The grading criteria — what counts as a good answer | rubric.criteria[] or a saved rubric template |
| Student answer | The student’s actual submission | textToGrade or materialId |
Pattern 1 — Reading Comprehension (Passage + Questions)
A teacher assigns a reading passage and asks students to answer questions about it. Each question becomes a rubric criterion, and the passage goes inassignmentContent.
Pattern 2 — Essay / Open-Ended Writing (No Source Material)
When students write an original essay (no assigned reading), you don’t needassignmentContent at all. The rubric criteria describe what a good essay looks like.
Pattern 3 — Case Study Analysis (Scenario + Specific Questions)
Give the AI a case study asassignmentContent, then define criteria that test whether the student applied the right frameworks or identified the right issues.
Pattern 4 — Reusable Template for Repeated Assignments
When many students answer the same questions about the same material, save everything in a rubric template so you only define the rubric and passage once. Create the template once:Choosing the Right Pattern
| Scenario | Use assignmentContent? | Use a template? |
|---|---|---|
| Students answer questions about a specific reading | Yes | Yes, if grading multiple students |
| Students write an original essay with no assigned reading | No | Yes, if the rubric is reused across assignments |
| One-off grading of a single submission | Depends on whether there’s source material | No — use an inline rubric |
| Same assignment given to 30+ students | Yes (bake it into the template) | Yes |
| Case study or lab report with reference material | Yes | Optional |
Grading from Material
Grade an assignment that has already been uploaded as a material.Using Create and Process (Recommended for Text)
For text assignments, usecreateAndProcess to automatically wait for processing:
Full Example: Passage Reading + Question Answering
This end-to-end walkthrough shows the full lifecycle: create a reusable template with a passage baked in, grade multiple students against it, then pull a class-wide educator report.Step 1 — Create a Rubric Template with the Passage
_id from the response — that’s your TEMPLATE_ID.
Step 2 — Grade Each Student’s Submission
Repeat this for every student, keeping the sameassignmentId.
- Reads the rubric criteria (questions + what to look for)
- Reads the assignment content (the water cycle passage) as the source of truth
- Reads the student’s submission (their answers)
- Grades each answer against the passage, not against its own knowledge
- Returns per-criterion scores and feedback
Step 3 — Pull the Educator Report
After grading multiple students with the sameassignmentId, generate an aggregate report:
Inline Rubric with Assignment Content (No Template)
If you don’t need a reusable template, you can pass everything in a single request:Object Reference
RubricCriterion Object
| Field | Type | Required | Description |
|---|---|---|---|
title | string | Yes | Short name of the criterion. |
description | string | No | What you want graded. Written as instructions for the grader. |
pointsPossible | number | Yes | Maximum points this criterion can earn. |
Rubric Object (Request Input)
| Field | Type | Required | Description |
|---|---|---|---|
criteria | RubricCriterion[] | Yes | Must have ≥ 1 entry. |
assignmentContent | string | No | Optional source material (superseded by top-level assignmentContent). |
GradedRubricCriterion Object (Response)
| Field | Type | Description |
|---|---|---|
title | string | Mirrors the input criterion title. |
description | string | Mirrors the input criterion description. |
pointsAwarded | number | Points the AI awarded. |
pointsPossible | number | Maximum points for this criterion. |
feedback | string | Per-criterion feedback (second-person, addressed to the student). |
AssignmentGrader Object
| Field | Type | Description |
|---|---|---|
_id | string (ObjectId) | Document ID. |
title | string | Assignment title. |
grade | number | Overall percentage (0–100), rounded to nearest whole number. |
rubric.attemptFeedback | string | Holistic feedback for the whole submission. |
rubric.criteria | GradedRubricCriterion[] | Per-criterion results. |
organizationId | string | Owning organization. |
userId | string | null | User who triggered the grading (or null for API-key auth). |
materialId | string? | Material that was graded (mutually exclusive with textToGrade). |
textToGrade | string? | Raw text that was graded. |
rubricTemplateId | string? | Template used (if any). |
assignmentId | string? | Grouping tag for educator reports. |
studentIdentifier | string? | Student email or ID. |
assignmentContent | string? | Source material the AI used. |
createdAt | Date | Timestamp. |
updatedAt | Date | Timestamp. |
RubricTemplate Object
| Field | Type | Description |
|---|---|---|
_id | string (ObjectId) | Template ID. |
name | string | Template name. |
description | string? | Optional description. |
assignmentContent | string? | Default source material attached to this template. |
criteria | RubricCriterion[] | Grading criteria. |
organizationId | string | Owning organization. |
createdBy | string | User who created the template. |
createdAt | Date | Timestamp. |
updatedAt | Date | Timestamp. |
Error Responses
All errors follow the standard exception envelope.| Status | When |
|---|---|
400 Bad Request | Invalid body — missing required fields, both materialId and textToGrade supplied, neither rubric nor template provided, empty rubric, or unknown grader action. |
401 Unauthorized | Missing or invalid x-api-key / Authorization header. |
404 Not Found | Assignment, template, or report target not found in your organization. |
500 Internal Server Error | Unexpected failure (AI service error, DB failure, etc.). |
Tips & Best Practices
- Provide
assignmentContentwhenever possible. It dramatically improves grading accuracy because the AI grades against the actual source instead of guessing. - Keep
assignmentContentfocused. Paste the actual passage or prompt students received. Don’t include instructions meant for the grader — put those in the criteriondescriptionfields instead. - Use criterion descriptions as grading instructions. For example: “Award full points only if the student names ≥2 specific dates from the passage.”
- Save templates for repeated assignments. If 30 students are all answering the same reading comprehension, create a template once and reuse it with
rubricTemplateId. - Always set
assignmentIdandstudentIdentifierwhen you plan to run an educator report. WithoutassignmentId, the report can’t aggregate submissions. - Top-level wins for
assignmentContent. If you need a one-off override of the template’s saved content, just includeassignmentContentat the top level of the grading request. - Cap on inputs. Materials larger than ~30k chars per item are truncated for grading; very large materials (>100k chars) are also truncated when extracted.
- Strict grading. The grader awards 0 points for factually incorrect answers. Post-processing also detects keywords like “incorrect”, “wrong”, “opposite” in the AI’s per-criterion feedback and forces
pointsAwardedto 0 (unless the feedback also indicates partial correctness with words like “partially”, “mostly”).