/mail/{id}/read
PUTMark an email as read or unread.
PUT /api/mail/{id}/read
Description
The /mail/{id}/read endpoint allows you to update the read status of a specific email. Send a PUT request with a JSON body containing is_read: true to mark as read, or is_read: false to mark as unread.
Status Update
This endpoint only updates the read/unread flag. It does not move the email or modify any other properties.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id |
string | Yes | The unique email identifier (32-character hexadecimal string). |
Request Body
The request must include a JSON body specifying the desired read status.
| Parameter | Type | Required | Description |
|---|---|---|---|
is_read |
boolean | Yes | Set to true to mark as read, false to mark as unread. |
Example Request Body
{
"is_read": true
}
Response
Returns a JSON object confirming the status update.
Response Properties
status
string
Operation status. Typically "success".
email_id
string
The ID of the email that was updated.
is_read
boolean
The new read status of the email.
Example Response
{
"status": "success",
"email_id": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6",
"is_read": true
}
Try It Out
Examples
JavaScript (async/await)
const API_BASE = 'http://localhost:8080/api';
const emailId = 'a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6';
async function markEmailAsRead(emailId, isRead = true) {
try {
const response = await fetch(`${API_BASE}/mail/${emailId}/read`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ is_read: isRead })
});
const result = await response.json();
if (result.status === 'success') {
console.log(`Email ${result.email_id} marked as ${result.is_read ? 'read' : 'unread'}`);
}
return result;
} catch (error) {
console.error('Error updating read status:', error);
}
}
// Mark as read
markEmailAsRead(emailId, true);
// Mark as unread
// markEmailAsRead(emailId, false);
cURL
# Mark email as read
curl -X PUT "http://localhost:8080/api/mail/a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6/read" \
-H "Content-Type: application/json" \
-d '{"is_read": true}'
# Mark email as unread
curl -X PUT "http://localhost:8080/api/mail/a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6/read" \
-H "Content-Type: application/json" \
-d '{"is_read": false}'
Python
import requests
API_BASE = 'http://localhost:8080/api'
email_id = 'a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6'
def mark_email_as_read(email_id, is_read=True):
response = requests.put(
f'{API_BASE}/mail/{email_id}/read',
json={'is_read': is_read}
)
result = response.json()
if result['status'] == 'success':
status = 'read' if result['is_read'] else 'unread'
print(f"Email {result['email_id']} marked as {status}")
return result
# Mark as read
mark_email_as_read(email_id, True)
# Mark as unread
# mark_email_as_read(email_id, False)