1. API Purpose
The Engagement API provides the interactive layer for the Skole platform. It allows parents and staff to acknowledge content (reactions) and ask clarifying questions (comments) on activities, diary entries, and notices.2. Endpoint Definition
| Method | Route | Auth | Description |
|---|---|---|---|
| POST | /parent-app/engagement/comment | 🔐 JWT | Post a new comment |
| GET | /parent-app/engagement/comments/:type/:id | 🔐 JWT | List comments for an entity |
| POST | /parent-app/engagement/react | 🔐 JWT | Toggle a reaction (Like/Love) |
| GET | /parent-app/engagement/reactions/:type/:id | 🔐 JWT | Get counts and user’s reaction state |
3. Authentication Flow
Standard JWT validation.- All engagement is tied to the
parent_idorstaff_idextracted from the token. skole_idscoping ensures users only engage with content within their school.
4. Request Structure
POST /parent-app/engagement/comment
Request Body:POST /parent-app/engagement/react
Request Body:GET /parent-app/engagement/comments/:type/:id
URL Parameters:| Field | Type | Description |
|---|---|---|
| type | string | Entity type (activity, diary, write_to). |
| id | number | ID of the specific entity. |
GET /parent-app/engagement/reactions/:type/:id
URL Parameters:| Field | Type | Description |
|---|---|---|
| type | string | Entity type. |
| id | number | Entity ID. |
5. Response Structure
Success: Comment Posted (201 Created)
Route:POST /parent-app/engagement/comment
Success: Comment List (200 OK)
Route:GET /parent-app/engagement/comments/:type/:id
Success: Reaction Toggled (200 OK)
Route:POST /parent-app/engagement/react
Success: Reaction Stats (200 OK)
Route:GET /parent-app/engagement/reactions/:type/:id
6. Error Responses
| HTTP Code | Description |
|---|---|
| 400 | Invalid entity_type (must be activity/diary/write_to/noticeboard) |
| 404 | Target entity not found |
7. Security Considerations
- Unique Constraint: The database enforces a
@@unique([entity_type, entity_id, parent_id, staff_id])constraint to prevent duplicate reactions from the same user. - Toggle Logic: If the same
reaction_typeis sent twice, the reaction is removed (unlike standard social platforms).
8. Token Usage
9. Token Refresh
N/A.10. Logout / Session Invalidation
N/A.11. Usage Example (cURL)
12. Notes / Special Behaviors
- Cross-Module Linkage: The
entity_typefield allows one API to handle engagement for multiple modules without logic duplication. - Moderation: Deleted comments (
deleted_status = 1) are filtered out at the service layer during listing.