# POST /mail/queue/delete

First published 14 Oct 2026 (release 0.2.0) · Unchanged since publication

UrbeStack release 0.2.35 API operation in the mail group.

Delete queued messages by queue ID or sender

- Who may call it: administrator, reseller
- Token scope, any of: mail, all
- Answers: 200 OK

Administrators can supply either ids or sender. UrbeStack deletes the messages selected by queue ID in one batch. Selection by sender deletes every queued message from that sender email address. UrbeStack sends no deletion notifications to senders.

Resellers must supply sender on one of their own domains or one of their customers' domains. A reseller request without a sender returns 403. The API returns 400 if both fields are supplied or if an administrator's request by queue ID lacks a nonempty ids list of queue IDs with 6 to 20 uppercase hexadecimal characters each.

The response includes ids and deleted. When the request selects by sender, the response also includes sender.

## As a command

- [urbestack-mail-queue-del](https://urbestack.com/docs/commands/urbestack-mail-queue-del.md): Deletes selected messages from the Postfix queue or empties it with --all.

## Request body

JSON.

- `ids` (array of string, matching ^[A-F0-9]{6,20}$)
- `sender` (MailAddress): Sender email address whose queued messages are all selected for deletion.

## Example

Set $API to the base URL and $TOKEN to the token, as the [API overview](https://urbestack.com/docs/api.md) shows.

```
curl -sS -X POST "$API/mail/queue/delete" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "ids": [
      "text"
    ],
    "sender": "text"
  }'
```

Response, 200 OK:

```
{
  "deleted": 1,
  "ids": [
    "text"
  ],
  "sender": "text"
}
```

## Errors

- 400: --id, --all or --sender is required
- 400: A queue id is 6 to 20 uppercase hexadecimal characters
- 400: At most 1000 messages are removed in one call
- 400: Domain name required
- 400: Domain name too long
- 400: Give ids or a sender, not both
- 400: Invalid domain name
- 400: Invalid mail address
- 400: Invalid mail address: local part over 64 characters
- 400: Invalid mail address: no local part
- 400: Invalid mail address: the local part may hold letters, digits, dots, _ + and -
- 400: No queue id was given
- 400: The mail stack is not installed on this server
- 400: ids must be a list of queue ids
- 401: Authentication required
- 403: A reseller removes queued messages by sender
- 404: No mailbox <sender> here
- 404: No such user: <owner>
