Updated on 2026-07-27 GMT+08:00

Obtaining Object Tags

Function

This API obtains the tags of an object. For more information about object tags, see Adding Tags to an Object.

Authorization

To call this API, you must be the object owner or have the permissions to obtain object tags. You are advised to use IAM or bucket policies for authorization. For details about OBS authorization methods, see Differences Between OBS Permissions Control Methods.

  • If you use IAM for authorization, you need to use either role/policy-based authorization or identity policy-based authorization and configure the required permissions:
    • If you use role/policy-based authorization (IAM v3 APIs in the old IAM version), you must have the obs:object:GetObjectTagging (versioning disabled) and obs:object:GetObjectVersionTagging (versioning enabled or suspended) permissions. For details, see Creating a Custom IAM Policy.
    • If you use identity policy-based authorization (IAM v5 APIs in the new IAM version), you must have the obs:object:getObjectTagging (versioning disabled) and obs:object:getObjectVersionTagging (versioning enabled or suspended) permissions, as shown in the following table. For details, see Creating a Custom IAM Identity Policy.

      Action

      Access Level

      Resource Type (*: Required)

      Condition Key

      Alias

      Dependencies

      obs:object:getObjectTagging (versioning disabled)

      obs:object:getObjectVersionTagging (versioning enabled or suspended)

      Read

      object *

      -

      -

      -

  • If you use bucket policies for authorization, you must have the obs:object:GetObjectTagging (versioning disabled) and obs:object:GetObjectVersionTagging (versioning enabled or suspended) permissions. For details, see Creating a Custom Bucket Policy.

URI

GET /{object_key}?tagging

Calling Method

For details, see Calling APIs. Before calling this API, calculate the API signature and add it to the request.

You can debug this API in API Explorer.

Request Syntax

1
2
3
GET /objectname?tagging&versionId=versionid HTTP/1.1
Date: date 
Authorization: authorization string

URI Parameters

This request uses the headers described in Table 1.

Table 1 URI parameters

Parameter

Mandatory

Type

Description

tagging

Yes

String

Definition

An identifier that marks this request as related to object tagging.

Constraints

N/A

Range

N/A

Default Value

N/A

versionId

No

String

Definition

Version ID of the object whose tags are to be obtained. The corresponding response header is x-obs-version-id. If the specified version is a delete marker, OBS returns 404 Not Found.

Constraints

N/A

Range

A string of 32 characters

Default Value

N/A

Request Headers

This request uses common headers. For details, see Table 3.

Request Body

This request contains no request body parameters.

Response Syntax

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
HTTP/1.1 status_code
x-obs-request-id: request id
x-obs-id-2: id
x-obs-version-id: version id
Content-Type: application/xml 
Content-Length: length
Date: date
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
    <TagSet> 
        <Tag> 
            <Key>key</Key> 
            <Value>value</Value> 
        </Tag> 
    </TagSet> 
</Tagging>

Response Headers

This response uses common headers. For details, see Table 1.

Response Body

This response contains elements that detail the configuration. Table 2 describes the elements.

Table 2 Response body parameters

Parameter

Type

Description

Tagging

XML

Definition

Container for the result of obtaining object tags.

Range

N/A

Error Responses

In addition to common error codes, this API also returns some special error codes. Table 3 lists the special error codes and their possible causes.

Table 3 Special errors for obtaining object tags

Error Code

Description

HTTP Status Code

NoSuchTagSet

No tags were configured for the specified object.

404

Sample Request

1
2
3
4
5
GET /objectname?tagging&versionId=G001018455096CE600005306000000DD HTTP/1.1   
User-Agent: curl/7.29.0   
Accept: */*   
Date: Wed, 27 Jun 2018 13:25:44 GMT  
Authorization: OBS H4IPJX0TQTHTHEBQQCEC:H1INcyc5i0XlHqYTfuzkPxLZUPM=

Sample Response

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
HTTP/1.1 200 OK 
x-obs-request-id: 0002B7532E0000015BEB35330C5884X1 
x-obs-id-2: s12w20LYNQqSb7moq4ibgJwmQRSmVQV+rFBqplOGYkXUpXeS/nOmbkyD+E35K79j 
x-obs-version-id: G001018455096CE600005306000000DD
Content-Type: application/xml 
Date: Wed, 27 Jun 2018 13:25:44 GMT 
Content-Length: 441 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  <TagSet>
    <Tag>
      <Key>TagName1</Key>
      <Value>TagSetValue1</Value>
    </Tag>
  </TagSet>
</Tagging>

Using SDKs to Call APIs

You are advised to use OBS SDKs to call APIs. SDKs encapsulate APIs to simplify development. You can call SDK API functions to access OBS without manually calculating signatures.

Java: not supported

PHP: not supported

Python: not supported

C: not supported

Go: not supported

BrowserJS: not supported

.NET: not supported

Android: not supported

iOS: not supported

Node.js: not supported

Helpful Links