Get Notifications (Admin)
Get all chat notifications for the authenticated admin.
Endpoint
Authentication
Required: Admin authentication token
Request
No request body required.
Response
Success (200 OK)
{
"success": true,
"message": "Notifications retrieved successfully",
"data": [
{
"id": 45,
"admin_id": 2,
"message_id": 123,
"session_id": 1,
"store_id": 5,
"store_name": "Tech Store",
"store_logo": "https://example.com/logo.jpg",
"content": "Hello, I need help with my account",
"is_read": false,
"created_at": "2025-12-16T10:15:00Z"
},
{
"id": 46,
"admin_id": 2,
"message_id": 125,
"session_id": 3,
"store_id": 8,
"store_name": "Fashion Boutique",
"store_logo": "https://example.com/logo2.jpg",
"content": "When will my order ship?",
"is_read": false,
"created_at": "2025-12-16T10:20:00Z"
},
{
"id": 44,
"admin_id": 2,
"message_id": 120,
"session_id": 1,
"store_id": 5,
"store_name": "Tech Store",
"store_logo": "https://example.com/logo.jpg",
"content": "Thank you for the help!",
"is_read": true,
"created_at": "2025-12-16T09:50:00Z"
}
]
}
No Notifications
Error (401 Unauthorized)
Error (403 Forbidden)
Response Fields
| Field | Type | Description |
|---|---|---|
id |
integer | Unique notification ID |
admin_id |
integer | ID of the admin |
message_id |
integer | ID of the message that triggered the notification |
session_id |
integer | ID of the chat session |
store_id |
integer | ID of the store |
store_name |
string | Name of the store |
store_logo |
string | URL to store logo |
content |
string | Message content (preview) |
is_read |
boolean | Whether notification has been read |
created_at |
string | ISO 8601 timestamp when notification was created |
Sorting
Notifications are sorted by creation time, with newest first.
Example Usage
JavaScript/Fetch
async function getNotifications() {
const response = await fetch('/v1/chat/admin/notifications/', {
method: 'GET',
headers: {
'Authorization': `Token ${adminToken}`
}
});
const data = await response.json();
if (data.success) {
const unread = data.data.filter(n => !n.is_read);
console.log(`Total notifications: ${data.data.length}`);
console.log(`Unread: ${unread.length}`);
data.data.forEach(notification => {
console.log(`${notification.store_name}: ${notification.content}`);
});
}
}
Axios
import axios from 'axios';
const getNotifications = async () => {
try {
const response = await axios.get('/v1/chat/admin/notifications/', {
headers: {
'Authorization': `Token ${adminToken}`
}
});
return response.data.data;
} catch (error) {
console.error('Failed to get notifications:', error);
}
};
cURL
curl -X GET "http://localhost:8000/v1/chat/admin/notifications/" \
-H "Authorization: Token your_admin_token_here"
Filtering Unread Notifications
const notifications = await getNotifications();
const unreadNotifications = notifications.filter(n => !n.is_read);
console.log('Unread notifications:', unreadNotifications);
Notes
- Notifications are created when a store sends a message while the admin is NOT on the messages page
- If the admin is actively chatting with a store, no notification is created for that session
- Notifications persist until explicitly marked as read
- Use Get Notification Count for just the count of unread notifications
- Click on a notification should:
- Navigate to the chat session
- Call Mark Notification Read
When Notifications Are Created
Notifications are created for admins when:
- A store sends a message in a session claimed by that admin
- The admin is currently NOT on the messages page
- The message is from the store (not another admin)
Notifications are NOT created when:
- Admin is actively viewing the messages page
- Message is sent by an admin (not a store)
- Session is not claimed by any admin (it's still "open")
Related Endpoints
- Get Notification Count - Get count of unread notifications
- Mark Notification Read - Mark a specific notification as read
- Mark All Notifications Read - Mark all as read
- Admin WebSocket - Receive real-time notification updates