Notification Settings
Manage notification settings for different types of content (letters, affirmations, questions, etc.). Control when and how frequently users receive notifications for each content type.
Get All Settings
Retrieve all notification settings for the authenticated user. If settings don't exist, they will be created with default values.
Endpoint
- Method: GET
- URL:
/api/notification-settings
Request Headers
| Header | Value | Required |
|---|---|---|
| Accept | application/json | Yes |
| Authorization | Bearer YOUR_API_TOKEN | Yes |
Success Response
{
"success": true,
"message": "تم جلب البيانات بنجاح",
"data": [
{
"type": "letter",
"start_time": "08:00:00",
"end_time": "21:00:00",
"reminders_per_day": 3,
"max_reminders_per_day": 5
},
{
"type": "affirmation",
"start_time": "08:00:00",
"end_time": "21:00:00",
"reminders_per_day": 3,
"max_reminders_per_day": 10
},
{
"type": "deconstruction_question",
"start_time": "08:00:00",
"end_time": "21:00:00",
"reminders_per_day": 2,
"max_reminders_per_day": 3
},
{
"type": "open_question",
"start_time": "08:00:00",
"end_time": "21:00:00",
"reminders_per_day": 1,
"max_reminders_per_day": 2
},
{
"type": "audio_affirmation",
"start_time": "08:00:00",
"end_time": "21:00:00",
"reminders_per_day": 3,
"max_reminders_per_day": 5
}
],
"status_code": 200
}
Error Response
Unauthorized (401)
{
"success": false,
"message": "Unauthenticated",
"data": null,
"status_code": 401
}
Update Settings
Update notification settings for a specific content type. After updating the settings, new scheduled notifications will be created based on the updated preferences. If settings don't exist for the specified type, they will be created.
Endpoint
- Method: POST
- URL:
/api/notification-settings
Request Headers
| Header | Value | Required |
|---|---|---|
| Content-Type | application/json | Yes |
| Accept | application/json | Yes |
| Authorization | Bearer YOUR_API_TOKEN | Yes |
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| type | string | Yes | Type of content. Must be one of: letter, affirmation, deconstruction_question, open_question, audio_affirmation |
| start_time | string | Yes | Start time for notifications in 24-hour format (HH:mm:ss) |
| end_time | string | Yes | End time for notifications in 24-hour format (HH:mm:ss) |
| reminders_per_day | integer | Yes | Number of reminders per day. Must be at least 1 and not exceed the maximum allowed for the content type |
Request Body Example
{
"type": "affirmation",
"start_time": "08:00:00",
"end_time": "21:00:00",
"reminders_per_day": 3
}
Success Response
{
"success": true,
"message": "تم إكمال العملية بنجاح",
"data": null,
"status_code": 200
}
Error Responses
Unauthorized (401)
{
"success": false,
"message": "Unauthenticated",
"data": null,
"status_code": 401
}
Validation Error (422)
{
"success": false,
"message": "نوع الإشعار يجب أن يكون واحداً من: letter, affirmation, deconstruction_question, open_question, audio_affirmation",
"data": null,
"status_code": 422
}
Invalid Time Format (422)
{
"success": false,
"message": "يجب أن يكون الوقت بتنسيق HH:mm:ss",
"data": null,
"status_code": 422
}
Invalid Reminders Count (422)
{
"success": false,
"message": "يجب أن يكون عدد التنبيهات اليومية على الأقل 1",
"data": null,
"status_code": 422
}
Example Implementation Flow
Update Notification Settings
- Get the user's API token from storage
- Prepare notification settings:
- Select content type (letter, affirmation, etc.)
- Set valid time range (start_time and end_time)
- Choose appropriate reminders_per_day
- Validate settings:
- Ensure time format is HH:mm:ss
- Check if reminders_per_day is within allowed range
- Verify content type is valid
- Make POST request to
/api/notification-settings - Upon success:
- Show success message in Arabic
- Update UI to reflect new settings
- Wait for scheduled notifications to be created
- Upon error:
- If validation fails (422), show which fields are invalid
- If unauthorized (401), redirect to login
- If server error, maintain current settings
- Display specific error messages for each case
Error Recovery
- If update fails:
- Keep previous settings active
- Show error message with details
- Provide retry option
- On validation error:
- Highlight problematic fields
- Show allowed values/formats
- Maintain valid field values