/api/qmail/mark-read
POSTMark an email message as read or unread.
POST /api/qmail/mark-read
Description
The POST /api/qmail/mark-read endpoint updates the read/unread status of a specific email. By default, calling this endpoint marks the email as read; pass is_read=false or is_read=0 to mark it as unread. This is useful for managing unread counts and tracking which messages have been viewed.
Status Flag Only
This endpoint only updates the read/unread flag. It does not move the email between folders or modify any other email properties.
Parameters
Send as form-encoded POST body or query parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
email_id |
string | Required | The unique email identifier (32-character hexadecimal GUID). |
is_read |
string | Optional | Set to "true" (default) to mark as read, or "0" / "false" to mark as unread. |
Response
Returns a JSON object confirming the updated read status.
Response Properties
success
boolean
Indicates whether the operation completed successfully.
email_id
string
The 32-character hex GUID of the email that was updated.
is_read
boolean
The current read state of the email after the operation.
Example Success Response (Marked Read)
{
"success": true,
"email_id": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6",
"is_read": true
}
Example Success Response (Marked Unread)
{
"success": true,
"email_id": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6",
"is_read": false
}
Example Error Response (400 Bad Request)
{
"success": false,
"message": "Missing required parameter: email_id"
}
Example Error Response (404 Not Found)
{
"success": false,
"message": "Failed to update read status"
}
Try It Out
Examples
cURL
# Mark email as read
curl -X POST "http://localhost:8080/api/qmail/mark-read" \
-d "email_id=a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6" \
-d "is_read=true"
# Mark email as unread
curl -X POST "http://localhost:8080/api/qmail/mark-read" \
-d "email_id=a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6" \
-d "is_read=false"
JavaScript (async/await)
const API_HOST = 'http://localhost:8080';
async function markEmailRead(emailId, isRead = true) {
try {
const params = new URLSearchParams();
params.append('email_id', emailId);
params.append('is_read', isRead.toString());
const response = await fetch(`${API_HOST}/api/qmail/mark-read`, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: params.toString()
});
const result = await response.json();
if (result.success) {
console.log(`Email ${result.email_id} marked as ${result.is_read ? 'read' : 'unread'}`);
} else {
console.error('Error:', result.error);
}
return result;
} catch (error) {
console.error('Error updating read status:', error);
}
}
// Mark as read
markEmailRead('a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6', true);
// Mark as unread
// markEmailRead('a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6', false);
Python
import requests
API_HOST = 'http://localhost:8080'
def mark_email_read(email_id, is_read=True):
response = requests.post(
f'{API_HOST}/api/qmail/mark-read',
data={
'email_id': email_id,
'is_read': 'true' if is_read else 'false'
}
)
result = response.json()
if result.get('success'):
status = 'read' if result['is_read'] else 'unread'
print(f"Email {result['email_id']} marked as {status}")
else:
print(f"Error: {result.get('error')}")
return result
# Mark as read
mark_email_read('a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6', True)
# Mark as unread
# mark_email_read('a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6', False)