Remove email account messages by mailbox GUID

This function removes mail messages from a cPanel account.

Important:

When you disable the Receive Mail role, the system disables this function.

SecurityBasicAuth
Request
query Parameters
account
required
string

The email account's name.

Example: account=user@example.com
mailbox_guid
required
string

The mailbox's globally unique identifier (GUID).

Note:

To find the mailbox GUID, use the WHM API 1 - get_mailbox_status function.

Example: mailbox_guid=2550860f0c58d158c92a000044f0d230
query
required
string

The Dovecot search query to select which messages you wish to remove from the mailbox. For more information, read Dovecot's Search Query documentation.

Example: query=savedbefore 52w
Responses
200

HTTP Request was successful.

Response Schema: application/json
object
get/expunge_messages_for_mailbox_guid
Request samples
whmapi1 --output=jsonpretty \
  expunge_messages_for_mailbox_guid \
  account='user@example.com' \
  mailbox_guid='2550860f0c58d158c92a000044f0d230' \
  query='savedbefore 52w'
Response samples
application/json
{
  • "metadata": {
    • "command": "expunge_messages_for_mailbox_guid",
    • "reason": "OK",
    • "result": 1,
    • "version": 1
    }
}