1. API Purpose
The Write To module provides a structured ticketing system for parent-to-school communication. It replaces informal calls/notes with trackable threads for leave requests, complaints, and queries.2. Endpoint Definition
| Method | Route | Auth | Description |
|---|---|---|---|
| POST | /parent-app/write-to | 🔐 JWT | Submit a new request |
| GET | /parent-app/write-to | 🔐 JWT | View active/past requests |
| GET | /parent-app/write-to/:id | 🔐 JWT | View full conversation thread |
| POST | /parent-app/write-to/:id/reply | 🔐 JWT | Parent reply to a conversation |
| GET | /teachers-app/write-to | 🔐 JWT | Staff: View all school requests |
| POST | /teachers-app/write-to/:id/reply | 🔐 JWT | Staff: reply to a request |
| PUT | /teachers-app/write-to/:id | 🔐 JWT | Staff: Update status (e.g., Resolve) |
3. Authentication Flow
Standard JWT validation.- Parents can only see requests they created (
parent_idmatch). - Staff can see all requests for their school (
skole_idmatch).
4. Request Structure
POST /parent-app/write-to
Request Body:GET /parent-app/write-to
Query Parameters:| Field | Type | Required | Description |
|---|---|---|---|
| status | string | No | Filter by status (open/resolved). |
GET /parent-app/write-to/:id
URL Parameters:| Field | Type | Description |
|---|---|---|
| id | number | ID of the request thread. |
POST /parent-app/write-to/:id/reply
Request Body:GET /teachers-app/write-to
Query Parameters:| Field | Type | Required | Description |
|---|---|---|---|
| skole_id | string | Yes | School identifier. |
| staff_id | string | No | Filter by assigned staff. |
| status | string | No | Filter by status (pending/resolved). |
| request_type | string | No | Filter by type. |
POST /teachers-app/write-to/:id/reply
Request Body:PUT /teachers-app/write-to/:id
Request Body:5. Response Structure
Success: Request Submitted (201 Created)
Route:POST /parent-app/write-to
Success: Parent Request List (200 OK)
Route:GET /parent-app/write-to
Success: Full Thread View (200 OK)
Route:GET /parent-app/write-to/:id
Success: Staff Request Queue (200 OK)
Route:GET /teachers-app/write-to
Success: Reply Posted (201 Created)
Route:POST /{module}/write-to/:id/reply
Success: Ticket Resolved (200 OK)
Route:PUT /teachers-app/write-to/:id
6. Error Responses
| HTTP Code | Description |
|---|---|
| 403 | Forbidden: Attempting to access a request belonging to another parent |
| 400 | Missing leave_from_date for a leave type request |
7. Security Considerations
- Thread Integrity: Replies are linked via
write_to_id. - Role Scoping: Only staff with specific permissions can resolve tickets or assign them to others.
8. Token Usage
9. Token Refresh
N/A.10. Logout / Session Invalidation
N/A.11. Usage Example (cURL)
12. Notes / Special Behaviors
- Leave Logic: Submitting a
leavetype request automatically notifies the class teacher via push notification. - Auto-Close: Inactive resolved threads are archived after a defined period (e.g., 30 days).