curl --request POST \
--url https://api.example.com/api/notification/mark-read/{notification_id}{
"message": "<string>"
}Mark a specific notification as read for the authenticated user
curl --request POST \
--url https://api.example.com/api/notification/mark-read/{notification_id}{
"message": "<string>"
}{
"message": "Notification marked as read"
}
{
"detail": "Notification not found"
}
{
"detail": "Notification not found"
}
{
"detail": "Authorization header missing or invalid."
}
curl -X POST "https://api.expireeye.com/api/notification/mark-read/550e8400-e29b-41d4-a716-446655440000" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
const notificationId = "550e8400-e29b-41d4-a716-446655440000";
const accessToken = "your-jwt-token";
fetch(`https://api.expireeye.com/api/notification/mark-read/${notificationId}`, {
method: "POST",
headers: {
"Authorization": `Bearer ${accessToken}`,
},
})
.then(response => response.json())
.then(data => {
console.log(data.message); // "Notification marked as read"
})
.catch(error => console.error("Error:", error));
import requests
notification_id = "550e8400-e29b-41d4-a716-446655440000"
access_token = "your-jwt-token"
url = f"https://api.expireeye.com/api/notification/mark-read/{notification_id}"
headers = {
"Authorization": f"Bearer {access_token}"
}
response = requests.post(url, headers=headers)
if response.status_code == 200:
data = response.json()
print(data["message"])
else:
print(f"Error: {response.status_code}")
import axios from 'axios';
async function markNotificationAsRead(
notificationId: string,
accessToken: string
): Promise<void> {
try {
const response = await axios.post(
`https://api.expireeye.com/api/notification/mark-read/${notificationId}`,
{},
{
headers: {
Authorization: `Bearer ${accessToken}`,
},
}
);
console.log(response.data.message);
} catch (error) {
if (axios.isAxiosError(error) && error.response?.status === 404) {
console.error('Notification not found');
} else {
console.error('Failed to mark notification as read:', error);
}
}
}
import { useState } from 'react';
import axios from 'axios';
function useMarkNotificationAsRead() {
const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
const markAsRead = async (notificationId: string, accessToken: string) => {
setLoading(true);
setError(null);
try {
await axios.post(
`https://api.expireeye.com/api/notification/mark-read/${notificationId}`,
{},
{
headers: { Authorization: `Bearer ${accessToken}` },
}
);
return true;
} catch (err) {
setError('Failed to mark notification as read');
return false;
} finally {
setLoading(false);
}
};
return { markAsRead, loading, error };
}
// Usage
function NotificationItem({ notification, accessToken }) {
const { markAsRead, loading } = useMarkNotificationAsRead();
const handleMarkAsRead = async () => {
const success = await markAsRead(notification.id, accessToken);
if (success) {
// Update UI to show notification as read
}
};
return (
<div onClick={handleMarkAsRead}>
{!notification.isRead && <span className="unread-badge" />}
<p>{notification.message}</p>
{loading && <span>Marking as read...</span>}
</div>
);
}
read field in the database is set to True upon successful execution