Notifications API
Endpoints for managing notifications and user preferences.Get Notifications
Retrieve user notifications.curl -X GET "https://api.usmewe.com/v1/notifications?limit=20" \
-H "Authorization: Bearer YOUR_TOKEN"
{
"success": true,
"data": [
{
"id": "notif_1",
"type": "loan_due_reminder",
"title": "Loan Payment Due Tomorrow",
"body": "Your loan #123 is due tomorrow. Total: $51.35",
"read": false,
"data": {
"loanId": "loan_123",
"amount": 51.35,
"dueDate": "2024-01-16T12:00:00Z"
},
"createdAt": "2024-01-15T09:00:00Z"
},
{
"id": "notif_2",
"type": "guardian_request",
"title": "Guardian Request",
"body": "Bob wants you to be their guardian",
"read": true,
"data": {
"requesterId": "user_bob",
"requesterName": "Bob"
},
"createdAt": "2024-01-14T15:00:00Z"
}
],
"pagination": {
"total": 45,
"limit": 20,
"offset": 0,
"hasMore": true
},
"unreadCount": 3
}
Query Parameters
| Parameter | Type | Description |
|---|---|---|
limit | number | Results per page (default: 20) |
offset | number | Pagination offset |
unread | boolean | Filter unread only |
type | string | Filter by notification type |
Get Unread Count
Get count of unread notifications.curl -X GET "https://api.usmewe.com/v1/notifications/unread/count" \
-H "Authorization: Bearer YOUR_TOKEN"
{
"success": true,
"data": {
"unreadCount": 3
}
}
Mark as Read
Mark notifications as read.Single Notification
curl -X PATCH "https://api.usmewe.com/v1/notifications/{notifId}/read" \
-H "Authorization: Bearer YOUR_TOKEN"
{
"success": true,
"data": {
"id": "notif_1",
"read": true
}
}
Mark All Read
curl -X POST "https://api.usmewe.com/v1/notifications/read-all" \
-H "Authorization: Bearer YOUR_TOKEN"
{
"success": true,
"data": {
"markedRead": 3
}
}
Delete Notification
Delete a notification.curl -X DELETE "https://api.usmewe.com/v1/notifications/{notifId}" \
-H "Authorization: Bearer YOUR_TOKEN"
{
"success": true,
"message": "Notification deleted"
}
Notification Types
| Type | Description |
|---|---|
loan_created | Loan request created |
loan_funded | Loan has been funded |
loan_due_reminder | Payment due reminder |
loan_overdue | Loan is overdue |
loan_repaid | Loan successfully repaid |
guardian_request | Guardian invitation received |
guardian_accepted | Guardian accepted invitation |
withdrawal_requested | Social Vault withdrawal pending |
withdrawal_approval_needed | Guardian approval needed |
vault_locked | Social Vault locked (duress) |
trust_score_updated | Trust Score changed |
level_up | User leveled up |
badge_earned | New badge earned |
Notification Preferences
Get Preferences
curl -X GET "https://api.usmewe.com/v1/notifications/preferences" \
-H "Authorization: Bearer YOUR_TOKEN"
{
"success": true,
"data": {
"push": {
"enabled": true,
"loan_reminders": true,
"guardian_alerts": true,
"marketing": false
},
"email": {
"enabled": true,
"loan_reminders": true,
"guardian_alerts": true,
"weekly_summary": true,
"marketing": false
},
"sms": {
"enabled": false
}
}
}
Update Preferences
curl -X PATCH "https://api.usmewe.com/v1/notifications/preferences" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"push": {
"marketing": false
},
"email": {
"weekly_summary": false
}
}'
{
"success": true,
"data": {
"push": {
"enabled": true,
"loan_reminders": true,
"guardian_alerts": true,
"marketing": false
},
"email": {
"enabled": true,
"loan_reminders": true,
"guardian_alerts": true,
"weekly_summary": false,
"marketing": false
}
}
}
Register Push Token
Register device for push notifications.curl -X POST "https://api.usmewe.com/v1/notifications/push/register" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"token": "ExponentPushToken[xxx]",
"platform": "ios",
"deviceId": "device_abc123"
}'
{
"success": true,
"data": {
"registered": true,
"deviceId": "device_abc123"
}
}
Unregister Push Token
Remove device from push notifications.curl -X DELETE "https://api.usmewe.com/v1/notifications/push/unregister" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"deviceId": "device_abc123"
}'
{
"success": true,
"message": "Device unregistered"
}
Test Notification
Send a test notification (development only).curl -X POST "https://api.usmewe.com/v1/notifications/test" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"type": "push"
}'
{
"success": true,
"message": "Test notification sent"
}
Error Responses
| Code | Error | Description |
|---|---|---|
| 404 | NOTIFICATION_NOT_FOUND | Notification doesn’t exist |
| 400 | INVALID_TOKEN | Invalid push token format |
| 429 | RATE_LIMITED | Too many requests |