# Change a queue's settings

Change a queue's visibility timeout, retention, delivery delay, receive wait, maximum message size or content-based deduplication.

Replace _my-queue_ with the name of your queue. The settings are defaults for new messages: a
message keeps the retention it was sent with, so a new retention applies to messages sent
afterwards. The ranges are in [Create a queue](create-a-queue.md). A queue's name and its type
(standard or FIFO) cannot be changed.

## Prerequisites

- Permission for `queue:SetQueueAttributes` on the queue. Without it, the console shows the
  settings but does not let you change them.
- For the console, also `queue:GetQueueAttributes` on the queue, to open its page.

## Change the settings

**Console**
1. Open the queue, then choose **Settings** (or, in the **⋯** menu, **Edit settings**).
2. Under **Delivery**, change **Visibility timeout (seconds)**, **Retention (seconds)**, **Delivery
   delay (seconds)**, **Receive wait (seconds)** or **Maximum message size (bytes)**.
3. Choose **Save**.

**Save** saves both sections of the page, the dead-letter queue included. Content-based
deduplication cannot be changed in the console.

**CLI**
```sh
dcloud queue queues set-attributes my-queue --visibility-timeout-seconds 120 --receive-wait-seconds 20
```

On a FIFO queue, `--content-based-deduplication` turns content-based deduplication on and
`--no-content-based-deduplication` turns it off.

**API**
```http
PATCH /queue/api/queues/my-queue
{ "visibilityTimeoutSeconds": 120, "receiveWaitSeconds": 20 }
```

Only the fields you send change. On a FIFO queue, `"contentBasedDeduplication": true` or `false`
turns content-based deduplication on or off.

**Terraform**
Change the arguments of the `dcloud_queue` resource (`visibility_timeout_seconds`,
`retention_seconds`, `delay_seconds`, `receive_wait_seconds`, `maximum_message_bytes`,
`content_based_deduplication`) and apply. Changing `name` or `fifo` replaces the queue and deletes
its messages.

## Result

The API answers `200` with the queue's new settings. New receives and sends use them at once.

## When a change is refused

- `400` "ContentBasedDeduplication applies only to FIFO queues." on a standard queue.
- `404` "There is no queue named “my-queue” here."

## Related

- [Set a dead-letter queue](set-a-dead-letter-queue.md)
- [Message delivery](message-delivery.md)
