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
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:GET /parent-app/engagement/reactions/:type/:id
URL Parameters: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
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.