Querying Object Tags

Last Updated At: 2025-10-21 09:10:00

Description

The GET Object tagging API is used to query existing tags of a specified object.
If you are using a sub-account to call this API, please make sure that you have obtained permission for the GET Object tagging API at the root account.

Versioning

If your bucket has versioning enabled and you need to query the tags of a specified version of the object, you can include the VersionId parameter when making the request, which will then query the tags of the specified version object.

Request

Request Example

GET /<ObjectKey>?tagging&VersionId=VersionId HTTP 1.1
Host:<BucketName-APPID>.<Endpoint>
Date: GMT Date
Authorization: Auth String

Description

  • indicates the bucket name with APPID as the suffix, for example, examplebucket-1250000000.
  • Authorization: Auth String (For details, refer to Request Signature).

Request Parameters

Name Description Type Required
versionId When versioning is enabled, specify the object VersionId to operate on. If not specified, the object tags of the latest version will be queried. string No

Request Header

This API only uses common request headers. For details, see Common Request Headers documentation.

Request Body

The request body of this request is empty.

Response

Response Headers

This API only returns the public response header. For details, see Common Response Headers documentation.

Response Body

Description of the response body nodes returned by this request:

Node Name (Keyword) Parent Node Description Type
Tagging No Tag Set Container
TagSet Tagging Tag Set Container
Tag Tagging.TagSet Tag set, supporting up to 10 tags Containers
Key Tagging.TagSet.Tag Tag key, with a length of less than 128 bytes, supporting letters, digits, spaces, plus signs, minus signs, underscores, equal signs, periods, colons, and slashes. String
Value Tagging.TagSet.Tag Tag value, with a length of less than 256 bytes, supporting letters, digits, spaces, plus signs, minus signs, underscores, equal signs, periods, colons, and slashes. String

Error Code

This API follows unified error response and error codes. For details, please refer to the Error Codes document.

Practical Case

Request

The following request queries the tags of the object exampleobject.txt in the bucket examplebucket-1250000000. After parsing the request, COS returns the tags {age:18} and {name:xiaoming} in the bucket.

GET /exampleobject.txt?tagging HTTP/1.1
User-Agent: curl/7.29.0
Accept: */*
Host: examplebucket-1250000000.cos.city.yfm4.fsphere.cn
Authorization: Auth String
Content-Md5: MD5 String
Content-Length: 127
Content-Type: application/xml

Response

HTTP/1.1 200 OK
Content-Type: application/xml
Connection: close
Date: Fri, 19 Jan 2020 11:40:22 GMT

<Tagging>
    <TagSet>
        <Tag>
            <Key>age</Key>
            <Value>18</Value>
        </Tag>
        <Tag>
            <Key>name</Key>
            <Value>xiaoming</Value>
        </Tag>
    </TagSet>
</Tagging>