/api/qmail/delete-permanent

DELETE

Permanently delete an email that is already in the trash.

DELETE /api/qmail/delete-permanent

Description

The DELETE /api/qmail/delete-permanent endpoint permanently and irreversibly deletes an email and all its associated attachments. The email must already be in the trash folder before it can be permanently deleted. This is a two-step safety mechanism: first trash with /api/qmail/trash, then permanently delete.

Irreversible Operation

This action cannot be undone. The email and all associated attachments will be permanently removed from the database. Make sure the email is already in trash before calling this endpoint.

Parameters

Send as query parameters or form-encoded body:

Parameter Type Required Description
email_id string Required The unique email identifier (32-character hexadecimal GUID).

Response

Returns a JSON object confirming permanent deletion.

Response Properties

success boolean
Indicates whether the operation completed successfully.
message string
"Email permanently deleted"

Example Success Response

{
  "success": true,
  "message": "Email permanently deleted"
}

Example Error Response (400 - Not in Trash)

{
  "success": false,
  "message": "Email must be in trash before permanent deletion. Use DELETE /api/qmail/trash first."
}

Example Error Response (404 Not Found)

{
  "success": false,
  "message": "Email not found"
}

Try It Out

Enter a 32-character hexadecimal email ID. The email must already be in trash.

Examples

cURL

# First, trash the email (if not already trashed)
curl -X DELETE "http://localhost:8080/api/qmail/trash?email_id=a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6"

# Then permanently delete it
curl -X DELETE "http://localhost:8080/api/qmail/delete-permanent?email_id=a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6"

JavaScript (async/await)

const API_HOST = 'http://localhost:8080';

async function deletePermanently(emailId) {
    try {
        const response = await fetch(
            `${API_HOST}/api/qmail/delete-permanent?email_id=${emailId}`,
            { method: 'DELETE' }
        );
        const result = await response.json();

        if (result.success) {
            console.log(result.message);
        } else {
            console.error('Error:', result.message);
        }
        return result;
    } catch (error) {
        console.error('Error permanently deleting email:', error);
    }
}

// Two-step deletion: trash first, then delete permanently
async function trashAndDelete(emailId) {
    // Step 1: Trash the email
    await fetch(`${API_HOST}/api/qmail/trash?email_id=${emailId}`, { method: 'DELETE' });

    // Step 2: Permanently delete
    return deletePermanently(emailId);
}

deletePermanently('a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6');

Python

import requests

API_HOST = 'http://localhost:8080'

def delete_permanently(email_id):
    response = requests.delete(
        f'{API_HOST}/api/qmail/delete-permanent',
        params={'email_id': email_id}
    )
    result = response.json()

    if result.get('success'):
        print(result['message'])
    else:
        print(f"Error: {result.get('message')}")

    return result

def trash_and_delete(email_id):
    """Two-step deletion: trash first, then permanently delete."""
    # Step 1: Trash
    requests.delete(f'{API_HOST}/api/qmail/trash', params={'email_id': email_id})
    # Step 2: Permanently delete
    return delete_permanently(email_id)

delete_permanently('a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6')

Related Endpoints

/api/qmail/trash

Soft-delete an email by moving it to trash (required before permanent deletion).

/api/qmail/delete

Legacy soft-delete endpoint (also moves to trash).

/api/qmail/inbox

List emails in a folder.