Creates a new post in the class (announcement, event, or general discussion).
Body
Required
-
ID of the class
-
Content of the post
-
Type of post
Values are
announcement,schedule_event, orgeneral. -
Array of attachment URLs
-
Array of linked resource IDs (individual resource IDs, not lessons)
-
If linking a lesson, provide lesson ID. Lesson resources will be mapped to post automatically
-
Whether to pin the post
-
Whether comments are allowed
POST
/classes/{classId}/posts
curl \
--request POST 'https://api.huy-devops.site/api/classes/{classId}/posts' \
--header "Authorization: Bearer $ACCESS_TOKEN" \
--header "Content-Type: application/json" \
--data '{"classId":"550e8400-e29b-41d4-a716-446655440000","content":"Check out this lesson on quadratic equations","type":"announcement","attachments":["https://example.com"],"linkedResourceIds":["string"],"linkedLessonId":"550e8400-e29b-41d4-a716-446655440005","isPinned":false,"allowComments":true}'
Request examples
{
"classId": "550e8400-e29b-41d4-a716-446655440000",
"content": "Check out this lesson on quadratic equations",
"type": "announcement",
"attachments": [
"https://example.com"
],
"linkedResourceIds": [
"string"
],
"linkedLessonId": "550e8400-e29b-41d4-a716-446655440005",
"isPinned": false,
"allowComments": true
}
Response examples (201)
{
"success": true,
"code": 200,
"message": "string",
"data": {
"id": "550e8400-e29b-41d4-a716-446655440008",
"classId": "550e8400-e29b-41d4-a716-446655440000",
"authorId": "550e8400-e29b-41d4-a716-446655440001",
"author": {
"id": "string",
"firstName": "string",
"lastName": "string",
"avatarUrl": "string"
},
"content": "Check out this lesson on quadratic equations",
"type": "announcement",
"attachments": [
"https://example.com/file.pdf"
],
"linkedResources": [
"550e8400-e29b-41d4-a716-446655440005"
],
"linkedLesson": {
"id": "string",
"title": "string",
"resources": [
{
"id": "550e8400-e29b-41d4-a716-446655440006",
"lessonId": "550e8400-e29b-41d4-a716-446655440005",
"name": "Quadratic Formula Worksheet",
"type": "document",
"url": "https://example.com/worksheet.pdf",
"filePath": "/uploads/worksheet.pdf",
"description": "Practice worksheet for quadratic equations",
"isRequired": true,
"isPrepared": false,
"createdAt": "2024-01-15T10:30:00Z"
}
]
},
"isPinned": false,
"allowComments": true,
"createdAt": "2024-09-20T10:30:00Z",
"updatedAt": "2024-09-20T14:45:00Z"
}
}
Response examples (400)
{
"success": false,
"code": 42,
"errorCode": "string",
"message": "string",
"timestamp": "2026-05-04T09:42:00Z"
}
Response examples (401)
{
"success": false,
"code": 42,
"errorCode": "string",
"message": "string",
"timestamp": "2026-05-04T09:42:00Z"
}
Response examples (404)
{
"success": false,
"code": 42,
"errorCode": "string",
"message": "string",
"timestamp": "2026-05-04T09:42:00Z"
}
Response examples (500)
{
"success": false,
"code": 42,
"errorCode": "string",
"message": "string",
"timestamp": "2026-05-04T09:42:00Z"
}