Skip to main content
POST
/
v1
/
homeworks
/
:homeworkId
/
submissions
Create Homework Submission
curl --request POST \
  --url https://api.example.com/v1/homeworks/:homeworkId/submissions \
  --header 'Content-Type: <content-type>' \
  --header 'x-tenant-api-secret: <x-tenant-api-secret>' \
  --data '
{
  "studentId": "<string>",
  "files": {}
}
'
{
  "id": "sub_123456789",
  "homeworkId": "123e4567-e89b-12d3-a456-426614174000",
  "chatId": "chat_987654321",
  "status": "submitted",
  "chatIframeUrl": "https://chat.lexiconlabs.ai/?chat_id=chat_987654321",
  "createdAt": "2023-07-15T14:32:17Z",
  "analysis": "",
  "grade": ""
}

Create Homework Submission

This endpoint allows students to upload their homework files for review.

Path Parameters

homeworkId
string
required
The UUID of the homework being submitted

Request Body

studentId
string
required
The ID of the student submitting the homework
files
array of files
required
The files containing the student’s homework solution (max 10 files)

Headers

Content-Type
string
required
multipart/form-data
x-tenant-api-secret
string
required
Your API authentication key

Response

id
string
The unique identifier for the submission
homeworkId
string
The ID of the homework being submitted
chatId
string
The ID of the chat session created for this submission review
status
string
The current status of the submission. Possible values: ‘submitted’ (initial state), ‘reviewed’ (AI has reviewed), ‘approved’ (meets requirements), or ‘needs_revision’ (requires changes).
chatIframeUrl
string
URL for the chat interface
createdAt
string
Timestamp when the submission was created
analysis
string
AI analysis of the submission
grade
string
Grade assigned to the submission. Possible values: ‘A’, ‘B’, ‘C’, ‘D’, ‘E’, ‘F’.
{
  "id": "sub_123456789",
  "homeworkId": "123e4567-e89b-12d3-a456-426614174000",
  "chatId": "chat_987654321",
  "status": "submitted",
  "chatIframeUrl": "https://chat.lexiconlabs.ai/?chat_id=chat_987654321",
  "createdAt": "2023-07-15T14:32:17Z",
  "analysis": "",
  "grade": ""
}

Error Responses

Invalid input parameters
Invalid or missing API key
Homework not found
Processing error

Example Usage

cURL

curl -X POST "https://api.lexiconlabs.ai/v1/homeworks/123e4567-e89b-12d3-a456-426614174000/submissions" \
  -H "Content-Type: multipart/form-data" \
  -H "x-tenant-api-secret: YOUR_API_KEY" \
  -F "studentId=student123" \
  -F "[email protected]" \
  -F "[email protected]"

JavaScript

const formData = new FormData();
formData.append('studentId', 'student123');
formData.append('files', fileInput.files[0]);
formData.append('files', fileInput.files[1]);

// Replace with the actual homework UUID
const homeworkId = '123e4567-e89b-12d3-a456-426614174000';
fetch(`https://api.lexiconlabs.ai/v1/homeworks/${homeworkId}/submissions`, {
  method: 'POST',
  headers: {
    'x-tenant-api-secret': 'YOUR_API_KEY'
  },
  body: formData
})
.then(response => response.json())
.then(data => {
  const chatId = data.chatId;
  // Redirect to chat interface or embed iframe
  window.location.href = `https://chat.lexiconlabs.ai/?chat_id=${chatId}`;
})
.catch(error => console.error('Error:', error));