The SetQueueAttributes action sets an attribute of a queue. Currently, you
can set two attributes for a queue: VisibilityTimeout and Policy. When you
change a queue's attributes, the change can take up to 60 seconds to propagate throughout the SQS
system.
![]() | Important |
|---|---|
Before the 2007-05-01 release introduced the |
The following table lists the special request parameters the
SetQueueAttributes action uses in addition to the common request parameters
all actions use (for more information, see Request Parameters Common to All Actions).
| Name | Description | Required |
|---|---|---|
|
|
The name of the attribute you want to set, either Type: String Valid Values: Default: None |
Yes |
|
|
The value of the attribute you want to set. To delete a queue's access control policy, set the policy to "". Constraints: For Default: None |
Yes |
The response contains no special elements besides the common elements in all successful responses (for more information, see Structure of a Successful Response).
The following table lists the special errors the SetQueueAttributes action
returns in addition to the common errors all actions return (for more information, see Errors Common to all Actions).
| Error | Description | HTTP Status Code |
|---|---|---|
|
|
Unknown attribute |
400 |
The following example Query request sets a policy that gives all users ReceiveMessage permission for the queue named 195004372649/testQueue.
https://queue.amazonaws.com?SignatureVersion=1 &Action=SetQueueAttributes &Version=2009-02-01 &Attribute.1.Name=Policy &Attribute.1.Value=%7B%22Version%22%3A%222008-10-17%22%2C%22Id%22 %3A%22%2F195004372649%2FtestQueue%2FSQSDefaultPolicy%22%2C%22Stat ement%22%3A%5B%7B%22Sid%22%3A%22Queue1ReceiveMessage%22%2C%22Effe ct%22%3A%22Allow%22%2C%22Principal%22%3A%7B%22AWS%22%3A%22*%22%7D %2C%22Action%22%3A%22SQS%3AReceiveMessage%22%2C%22Resource%22%3A% 22%2F195004372649%2FtestQueue%22%7D%5D%7D &Timestamp=2009-05-06T16%3A57%3A31.000Z &AWSAccessKeyId=0AZAVD7PQ3DCC3452ZG2 &Signature=%2Bd7ZlPIdnb%2BhpEna2TgfwQjfGF8%3D
The above policy value is form-url-encoded from the following text:
{
"Version":"2008-10-17",
"Id":"/195004372649/testQueue/SQSDefaultPolicy",
"Statement": [
{
"Sid":"Queue1ReceiveMessage",
"Effect":"Allow",
"Principal":{"AWS":"*"},
"Action":"SQS:ReceiveMessage",
"Resource":"/195004372649/testQueue"
}
]
}For more examples of policies, see Amazon SQS Policy Examples.
The following example Query request sets the visibility timeout to 35 seconds for the queue named 123456789012/testQueue.
http://queue.amazonaws.com/123456789012/testQueue/ ?Action=SetQueueAttributes &Attribute.1.Name=VisibilityTimeout &Attribute.1.Value=35 &Version=2009-02-01 &SignatureMethod=HmacSHA256 &Expires=2009-04-18T22%3A52%3A43PST &AWSAccessKeyId=0GS7553JW74RRM612K02EXAMPLE &SignatureVersion=2 &Signature=Dqlp3Sd6ljTUA9Uf6SGtEExwUQEXAMPLE
<SetQueueAttributesResponse>
<ResponseMetadata>
<RequestId>
e5cca473-4fc0-4198-a451-8abb94d02c75
</RequestId>
</ResponseMetadata>
</SetQueueAttributesResponse>