PUT Bucket Tagging¶
The PUT Bucket Tagging operation uses the tagging subresource to add a set
of tags to an existing bucket.
A tag is a key/value pair. You can associate tags with a bucket by sending a PUT request against the tagging subresource associated with the bucket. To retrieve tags, send a GET request. You can associate up to 50 tags per S3 Bucket. For more information, refer to GET Bucket Tagging.
This operation requires permission to perform the s3:PutBucketTagging
action. By default, the bucket owner has this permission and can grant it
to others.
Requests¶
Syntax¶
The following request shows the syntax for sending tagging information to the request body.
GET /?tagging HTTP/1.1
Host: {{BucketName}}.{{StorageService}}.com
Date: {{date}}
Authorization: {{authorizationString}}
<Tagging>
<TagSet>
<Tag>
<Key>Tag Name</Key>
<Value>Tag Value</Value>
</Tag>
</TagSet>
</Tagging>
Parameters¶
The PUT Bucket Tagging operation does not use request parameters.
Headers¶
Content-MD5 is a required header for this operation.
Elements¶
Element |
Type |
Description |
Required |
|---|---|---|---|
|
container |
Container for the |
Yes |
|
container |
Contains the tag set Ancestor: |
Yes |
|
container |
Contains the tag information Ancestor: |
No |
|
string |
Name of the tag Ancestor: |
Yes, if |
|
string |
Value of the tag Ancestor: |
No |
Responses¶
Headers¶
The PUT Bucket Tagging operation uses only response headers common to all responses (refer to Common Response Headers).
Elements¶
The PUT Bucket Tagging operation does not return response elements.
Special Errors¶
InvalidTagError— The tag provided is not valid. This error can occur if the tag did not pass input validation. Refer to User-Defined Tag Restrictions for more information.MalformedXMLError— The XML provided does not match the schema.OperationAbortedError— A conflicting conditional operation is currently in progress against this resource. Try again.InternalError— The service is unable to apply the provided tag to the bucket.
Examples¶
Request¶
The following request adds a tag set to the existing {{BucketName}} bucket.
PUT ?tagging HTTP/1.1
Host: {{BucketName}}.s3.example.com
Content-Length: length
Content-MD5: pUNXr/BjKK5G2UKExample==
x-amz-date: 20160923T001956Z
Authorization: {{authorizationString}}
<Tagging>
<TagSet>
<Tag>
<Key>tag1</Key>
<Value>val1</Value>
</Tag>
<Tag>
<Key>tag2</Key>
<Value>val2</Value>
</Tag>
</TagSet>
</Tagging>
Response¶
HTTP/1.1 200 OK
x-amz-id-2: YgIPIfBiKa2bj0KMgUAdQkf3ShJTOOpXUueF6QKo
x-amz-request-id: 236A8905248E5A01
Date: Thu, 22 Sep 2016 21:33:08 GMT

