# Delete a queue

Delete a queue and every message in it.

Replace _my-queue_ with the name of your queue.

**Warning:**
The queue's messages are deleted with it and cannot be recovered. From then on, sends to the queue
fail with `QueueDoesNotExist`.

## Prerequisites

- Permission for `queue:DeleteQueue` on the queue. For the console, also
  `queue:GetQueueAttributes` on it, to open its page.
- No other queue uses it as its dead-letter queue. Otherwise the delete is refused with `409`
  "“my-queue-dlq” is the dead-letter queue of “my-queue”. Remove it there first.", and the console
  shows **Delete queue** as unavailable. Remove it from that queue first (see
  [Set a dead-letter queue](set-a-dead-letter-queue.md)), or delete that queue first.

## Delete the queue

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

The console returns to the queue list.

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

**API**
```http
DELETE /queue/api/queues/my-queue
```

The answer is `200` with the deleted queue's `name`.

**Terraform**
Remove the `dcloud_queue` resource from the configuration and apply, or run `terraform destroy`.

## Result

The queue and its messages are gone. Messages it had moved to its dead-letter queue stay there, but
a redrive can no longer send them back to it; redrive them to another queue instead (see
[Redrive a dead-letter queue](redrive-a-dead-letter-queue.md)).

## When the delete is refused

- `409` when another queue uses it as its dead-letter queue (see Prerequisites).
- `404` "There is no queue named “my-queue” here."

## Related

- [Purge a queue](purge-a-queue.md)
