/api/qmail/db/messages/trash
GET DELETEMove an email to trash on Client2.
Description
The /api/qmail/db/messages/trash endpoint performs a soft delete. It moves the email to the trash folder and returns "Email moved to trash". The email is identified by its 32-character hexadecimal GUID passed as the email_id query parameter.
Soft Delete
This endpoint does not permanently erase the message. Use /api/qmail/db/messages/delete if you need irreversible removal.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
email_id |
string | Yes | The unique email identifier. Must be a 32-character hexadecimal GUID string. |
Response
Returns a JSON object confirming the email was moved to trash.
Response Properties
success
boolean
Indicates whether the request was successful.
true on success.
message
string
A human-readable confirmation message. Returns
"Email moved to trash" on success.
email_id
string
The 32-character hex GUID of the email that was moved to trash.
Example Success Response
{
"success": true,
"message": "Email moved to trash",
"email_id": "a1b2c3d4e5f67890a1b2c3d4e5f67890"
}
Error Responses
// 400 Bad Request - Missing email_id
{
"error": true,
"message": "Missing required parameter: email_id",
"code": 400
}
// 400 Bad Request - Invalid format
{
"error": true,
"message": "Invalid email_id format",
"code": 400
}
// 404 Not Found - Email does not exist
{
"error": true,
"message": "Email not found",
"code": 404
}
Try It Out
Examples
cURL
# Move an email to trash (GET — easy browser/devtool testing)
curl "http://localhost:8082/api/qmail/db/messages/trash?email_id=a1b2c3d4e5f67890a1b2c3d4e5f67890"
# Move an email to trash (canonical DELETE)
curl -X DELETE "http://localhost:8082/api/qmail/db/messages/trash?email_id=a1b2c3d4e5f67890a1b2c3d4e5f67890"
JavaScript (async/await)
const API_BASE = 'http://localhost:8082/api';
const emailId = 'a1b2c3d4e5f67890a1b2c3d4e5f67890';
async function deleteEmail(emailId) {
try {
const response = await fetch(
`${API_BASE}/qmail/db/messages/trash?email_id=${emailId}`,
{ method: 'DELETE' }
);
const result = await response.json();
if (result.success) {
console.log(`Email ${result.email_id} deleted successfully`);
console.log(result.message);
} else {
console.error('Failed to delete email:', result.message);
}
return result;
} catch (error) {
console.error('Error deleting email:', error);
}
}
deleteEmail(emailId);
Python
import requests
API_BASE = 'http://localhost:8082/api'
email_id = 'a1b2c3d4e5f67890a1b2c3d4e5f67890'
def delete_email(email_id):
response = requests.delete(
f'{API_BASE}/qmail/db/messages/trash',
params={'email_id': email_id}
)
result = response.json()
if result.get('success'):
print(f"Email {result['email_id']} deleted successfully")
print(result['message'])
else:
print(f"Failed to delete email: {result.get('message')}")
return result
delete_email(email_id)
Related Endpoints
/api/qmail/db/messages/list
List emails from any folder to identify candidates for deletion.