Feature Overview
This API is used to set tags (key-value pairs) for an existing bucket so that you can better manage bucket resources and costs.
Note
Currently, the bucket tagging feature supports up to 50 different tags per bucket.
Requests
Sample Request
PUT /?tagging HTTP 1.1Host:<BucketName-APPID>.cos.<Region>.myqcloud.comDate: GMT DateAuthorization: Auth StringContent-MD5: MD5Content-Length: Content LengthContent-Type: application/xml[Request Body]
Note
Host: <BucketName-APPID>.cos.<Region>.myqcloud.com, where <BucketName-APPID> is the bucket name with the APPID suffix, such as examplebucket-1250000000. You can refer to the Bucket Overview > Basic Information and Bucket Overview > Bucket Naming Convention documentation. <Region> represents the available regions for COS, which can be found in the Regions and Access Domain Names documentation.
Authorization: Auth String (For more information, see Request Signature.)
Request Header
Request Body
You need to set the following tag set in the request body:
<?xml version="1.0" encoding="UTF-8" ?><Tagging><TagSet><Tag><Key>age</Key><Value>18</Value></Tag><Tag><Key>name</Key><Value>xiaoming</Value></Tag></TagSet></Tagging>
The nodes are described as follows:
Node Name (Keyword) | Parent Node | Description | Local Disk Types | Required |
Tagging | - | Tagging configuration | Container | Required |
TagSet | Tagging | Tagging configuration | Container | Required |
Tag | Tagging.TagSet | A single tag. Up to 50 tags are supported. | Containers | Required |
Key | Tagging.TagSet.Tag | Tag Key: Up to 128 bytes in length. Supports letters, digits, spaces, plus signs, hyphens, underscores, equal signs, periods, colons, and slashes. | String | Required |
Value | Tagging.TagSet.Tag | Tag Value: Up to 256 bytes in length. Supports letters, digits, spaces, plus signs, hyphens, underscores, equal signs, periods, colons, and slashes. | String | Required |
Response
Response Header
Response Body
The response body is empty.
Error Codes
Examples
Requests
The following example writes the {age:18} and {name:xiaoming} tags to the
examplebucket-1250000000 bucket. After these tags are successfully configured, COS returns 204 (success).PUT /?tagging HTTP/1.1User-Agent: curl/7.29.0Accept: */*Host: examplebucket-1250000000.cos.ap-chengdu.myqcloud.comAuthorization: q-sign-algorithm=sha1&q-ak=AKIDrbAYjEBqqdEconpFi8NPFsOjrnX4<1>**&q-sign-time=1516361923;1517361973&q-key-time=1516361923;1517361973&q-url-param-list=tagging&q-header-list=content-md5;host&q-signature=71251feb4501494edcfbd01747fa87300375</1>**Content-MD5: LIbd5t5HLPhuNWYkP6qHcQ==Content-Length: 127Content-Type: application/xml<Tagging><TagSet><Tag><Key>age</Key><Value>18</Value></Tag><Tag><Key>name</Key><Value>xiaoming</Value></Tag></TagSet></Tagging>
Response
HTTP/1.1 204 No ContentContent-Type: application/xmlContent-Length: 0Connection: keep-aliveDate: Fri, 19 Jan 2018 11:40:22 GMTServer: tencent-cosx-cos-request-id: NWE2MWQ5MjZfMTBhYzM1MGFfMTA5ODVfMTVj****