# Purge a queue

Delete every message in a queue at once, waiting, delayed and in flight, and keep the queue and its settings.

Replace _my-queue_ with the name of your queue.

**Warning:**
Purged messages cannot be recovered.

## Prerequisites

- Permission for `queue:PurgeQueue` on the queue. Without it, the console shows **Purge** as
  unavailable. For the console, also `queue:GetQueueAttributes` on it, to open its page.

## Purge the queue

**Console**
1. Open the queue, then choose **Danger zone** (or, in the **⋯** menu, **Purge messages**).
2. Under **Purge messages**, choose **Purge**.
3. In the dialog, enter the queue's name, and choose **Purge**.

**CLI**
```sh
dcloud queue queues purge my-queue
```

**API**
```http
POST /queue/api/queues/my-queue/purge
```

The answer is `200` with `deleted`, the number of messages deleted.

**Terraform:** not available. Purging is an action, not configuration.

## Result

The queue is empty. Messages it had already moved to its dead-letter queue stay there; purge the
dead-letter queue to delete those.

On a FIFO queue, the deduplication ids of the purged messages are kept: a send that repeats one
within five minutes of the original send is still treated as a duplicate and not stored.

## When the purge is refused

- `403` without `queue:PurgeQueue` on the queue.
- `404` "There is no queue named “my-queue” here."

## Related

- [Delete a queue](delete-a-queue.md)
- [Dead-letter queues](dead-letter-queues.md)
